A library that allows you to perform code on multiple devices at the same time, offline.
Synaction allows you to execute a block of code on different and multiple iDevices, all connected through the multipeer connectivity framework, at an (almost) exact time. It uses mach time and calculates the precise offset between the host device, and it's peers.
Add the library and header file into your project, they can be found in the Synaction Product
folder. And import Synaction.h
wherever you'll be using the class.
Bundled with Synaction is ConnectivityManager, a MultipeerConnectivity wrapper. Synaction uses it to send data between devices.
- Call
+sharedInstance
on Synaction to initialize it and the connectiivty manager. - On the host device call
-setupBrowser
and on the peers call-advertiseSelfInSessions:YES
. - To present the connection interface, on the view controller present the
browser
(property of the Connectivity Manager).
- First get an instance of Synaction by calling
+sharedManager
. - To execute code at the same time, first calculate the offset with the host, by calling
- calculateTimeOffsetWithHost
on the peer device(s) or- askPeersToCalculateOffset:
on the host. - Then use
- atExactTime:(uint64_t)val runBlock:(dispatch_block_t _Nonnull)block
to performblock
atval
nano time.val
should be a value in nanoseconds. - To accurately calculate this value you can get the current mach time in nano seconds with
- currentNetworkTime
for network adjusted time (synced) and- currentTime
for local device time.
##Documentation Documentation for the various functions will (hopefully) eventually be written. Meanwhile, the function names are pretty self explanatory, otherwise post an issue. If you'd like to contribute to the docs just submit a pull request.
Both the connectivity manager, and the core components of the mach time calculations were found online and modified. Connectivity Manager
Mach Time Article: I'm currently not able to find the article from where I pulled this. If you're the author, or have doubts of where it comes from please open an issue!
Check License file.