PhotonNetwork.time and networkingPeer.ServerTimeInMilliSeconds returning weird values?
Options
Hello! I have a question regarding the values returned from PhotonNetwork.time and networkingPeer.ServerTimeInMilliSeconds.
In my game, when a match starts (on the OnJoinRoom callback), I store the current server timestamp so I can create a timer for the match. Usually it works just fine, but every now and then, at the beginning of the match, these functions (I tried both) return 0 for a while and then jump back to the usual values.
Is this normal? And if so, is there some callback its guaranteed that I will get a correct timestamp?
Thanks!
In my game, when a match starts (on the OnJoinRoom callback), I store the current server timestamp so I can create a timer for the match. Usually it works just fine, but every now and then, at the beginning of the match, these functions (I tried both) return 0 for a while and then jump back to the usual values.
Is this normal? And if so, is there some callback its guaranteed that I will get a correct timestamp?
Thanks!
0
Best Answer
-
... every now and then, at the beginning of the match, these functions (I tried both) return 0 for a while and then jump back to the usual values.
It should not happen often, but it's to be expected.
The client attempts to fetch the server's timestamp when it connects any server (which is part of joining a room). To get a reasonably correct time, the roundtrip for that "fetch timestamp" message should be OK. If the roundtrip time is bad at the beginning, then we can't tell you the server's time for a while.
Sorry but if you need the timestamp, you sometimes have to wait for it, before you properly start the game for a client.
Also, sorry for the late reply. The question somehow escaped us.5
Answers
-
... every now and then, at the beginning of the match, these functions (I tried both) return 0 for a while and then jump back to the usual values.
It should not happen often, but it's to be expected.
The client attempts to fetch the server's timestamp when it connects any server (which is part of joining a room). To get a reasonably correct time, the roundtrip for that "fetch timestamp" message should be OK. If the roundtrip time is bad at the beginning, then we can't tell you the server's time for a while.
Sorry but if you need the timestamp, you sometimes have to wait for it, before you properly start the game for a client.
Also, sorry for the late reply. The question somehow escaped us.5 -
Oh no problem, but I can understand why it happened now, thanks!0