[英]Sync timers between two devices using Multipeer Connectivity?
I've come across a few posts that kind of address my issue, but none of them actually have the answer that I'm looking for. 我遇到了一些解决我的问题的帖子,但是他们中没有一个真的有我正在寻找的答案。 I'm using Multipeer Connectivity to connect between two devices, and I want to execute a block of code at the exact same time, with as little latency as possible.
我正在使用Multipeer Connectivity连接两个设备,我希望在完全相同的时间执行一段代码,并尽可能减少延迟。 I've gone through sending timestamps from the host to another peer to start a timer at the same time (with the Date class), but there is always at least 0.3 to 0.5 seconds of latency.
我已经通过从主机向另一个对等方发送时间戳来同时启动计时器(使用Date类),但总是存在至少0.3到0.5秒的延迟。 The problem is that the device times aren't synced perfectly.
问题是设备时间没有完全同步。 Is there any third-party framework or solution that would allow me to run code at the same time on both devices?
是否有任何第三方框架或解决方案允许我在两个设备上同时运行代码? One example of this is the app AmpMe, which syncs music across many devices.
其中一个例子是app AmpMe,它可以在许多设备上同步音乐。 I'm using Swift 3, by the way.
顺便说一句,我正在使用Swift 3。
我建议使用时间服务器来同步它们的时钟或计算它们的时钟之间的偏移量,然后使用这些偏移量在两个设备上的同一时刻启动你的定时器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.