In a server-client game using bluetooth connectivity (GameKit, specifically, for iOS6 compatibility), 1 or more client devices (iPhone/iTouch) send a timestamp to the server device (iPad) when a button on each client is tapped. i.e. each of the clients calls:
[[NSDate date] timeIntervalSince1970]
...and then sends to the server the value as an NSData
payload.
When only 1 client is connected, the time being generated and sent to the server is the same as the time of the physical tap. When 2 or more clients are connected, the generated times differ significantly, even if all the clients are tapped at exactly the same time, e.g.
Client 1 and 2 simultaneously tapped:
- client 1 timestamp = 1396974546.558433 (time interval since 1970)
- client 2 timestamp = 1396974551.274747 (time interval since 1970)
i.e. client 2 is somehow 5 seconds out from client 1. While I'd accept a few milliseconds of difference since truly simultaneous tapping is hard, multiple seconds is unacceptable. Adding additional clients generates a more or less random difference in times, but usually several seconds.
To make things even more mysterious, the timestamps are being generated differently on the client: the timestamps being received at the server are the same as those being generated by the client (i.e. it's not something happening in transit or on receipt).
I'm at a loss for what's causing this. Any ideas?