diff --git a/Synaction Product/libSynaction.a b/Synaction Product/libSynaction.a index 3b59387..e8c06d9 100644 Binary files a/Synaction Product/libSynaction.a and b/Synaction Product/libSynaction.a differ diff --git a/Synaction.xcodeproj/project.xcworkspace/xcuserdata/GeorgesKanaan.xcuserdatad/UserInterfaceState.xcuserstate b/Synaction.xcodeproj/project.xcworkspace/xcuserdata/GeorgesKanaan.xcuserdatad/UserInterfaceState.xcuserstate index 593d02c..acb692e 100644 Binary files a/Synaction.xcodeproj/project.xcworkspace/xcuserdata/GeorgesKanaan.xcuserdatad/UserInterfaceState.xcuserstate and b/Synaction.xcodeproj/project.xcworkspace/xcuserdata/GeorgesKanaan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Synaction/Synaction.m b/Synaction/Synaction.m index af0f777..93cf31f 100644 --- a/Synaction/Synaction.m +++ b/Synaction/Synaction.m @@ -96,7 +96,7 @@ - (uint64_t)currentNetworkTime {// https://developer.apple.com/library/content/q } uint64_t timeNanoSeconds = baseTime * sTimebaseInfo.numer / sTimebaseInfo.denom; - return timeNanoSeconds - self.hostTimeOffset; + return (int64_t)timeNanoSeconds - self.hostTimeOffset; } - (void)atExactTime:(uint64_t)val runBlock:(dispatch_block_t _Nonnull)block { @@ -108,8 +108,8 @@ - (void)atExactTime:(uint64_t)val runBlock:(dispatch_block_t _Nonnull)block { dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, DISPATCH_TIMER_STRICT, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)); dispatch_source_set_event_handler(timer, ^{ dispatch_source_cancel(timer); // one shot timer - while (val > [self currentNetworkTime]) { - [NSThread sleepForTimeInterval:0]; + while (val > [self currentNetworkTime]+(uint64_t)1) { + sleep(0); } block(); }); @@ -162,8 +162,8 @@ - (void)session:(MCSession *)session didReceiveData:(NSData *)data fromPeer:(MCP //uint64_t latencyWithHost = ([self currentNetworkTime] - timePingSent)/2;// Calculates the estimated latency for one way travel int64_t calculatedOffset = ((int64_t)[self currentNetworkTime] + (int64_t)timePingSent - (2*(int64_t)timeHostReceivedPing))/2; // WAY 1. Best because it doesn't depend on latency - //calculatedOffset2 = latencyWithHost - timeHostReceivedPing + timePingSent;// WAY 2 - //calculatedOffset3 = -latencyWithHost - timeHostReceivedPing + [self currentNetworkTime];// WAY 3 + //calculatedOffset2 = (int64_t)latencyWithHost - (int64_t)timeHostReceivedPing + (int64_t)timePingSent;// WAY 2 + //calculatedOffset3 = -(int64_t)latencyWithHost - (int64_t)timeHostReceivedPing + (int64_t)[self currentNetworkTime];// WAY 3 [calculatedOffsets addObject:[NSNumber numberWithLongLong:calculatedOffset]]; diff --git a/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/arm64/Synaction.o b/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/arm64/Synaction.o index 785ce69..b6af48d 100644 Binary files a/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/arm64/Synaction.o and b/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/arm64/Synaction.o differ diff --git a/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/arm64/libSynaction.a b/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/arm64/libSynaction.a index 1be019d..7cf6049 100644 Binary files a/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/arm64/libSynaction.a and b/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/arm64/libSynaction.a differ diff --git a/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/armv7/Synaction.o b/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/armv7/Synaction.o index b023179..3870665 100644 Binary files a/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/armv7/Synaction.o and b/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/armv7/Synaction.o differ diff --git a/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/armv7/libSynaction.a b/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/armv7/libSynaction.a index ee363e5..87ebc10 100644 Binary files a/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/armv7/libSynaction.a and b/build/Synaction.build/Debug-iphoneos/Synaction.build/Objects-normal/armv7/libSynaction.a differ diff --git a/build/Synaction.build/Debug-iphoneos/Synaction.build/dgph b/build/Synaction.build/Debug-iphoneos/Synaction.build/dgph index c34e0a8..d293497 100644 Binary files a/build/Synaction.build/Debug-iphoneos/Synaction.build/dgph and b/build/Synaction.build/Debug-iphoneos/Synaction.build/dgph differ diff --git a/build/Synaction.build/Debug-iphonesimulator/Synaction.build/Objects-normal/i386/Synaction.o b/build/Synaction.build/Debug-iphonesimulator/Synaction.build/Objects-normal/i386/Synaction.o index 8c73882..eb37846 100644 Binary files a/build/Synaction.build/Debug-iphonesimulator/Synaction.build/Objects-normal/i386/Synaction.o and b/build/Synaction.build/Debug-iphonesimulator/Synaction.build/Objects-normal/i386/Synaction.o differ diff --git a/build/Synaction.build/Debug-iphonesimulator/Synaction.build/dgph b/build/Synaction.build/Debug-iphonesimulator/Synaction.build/dgph index cad86dc..20be9a0 100644 Binary files a/build/Synaction.build/Debug-iphonesimulator/Synaction.build/dgph and b/build/Synaction.build/Debug-iphonesimulator/Synaction.build/dgph differ