How to read and use getServerTime()

SergiySergiy
edited August 2012 in Flash (deprecated)
Hello! How can I use getSeverTime() from PhotonCore?
I use RC-7, just make some traces affter connecting to PhotonServer, result is:
[trace] PhotonCore 3.0.0.3-RC7 created
[trace] 0
[trace] 27270420
[trace] 27271919
[trace] 27273933
[trace] 27275931

Why I have so huge number? As I understand, it should be maybe up to 3000 ms delay, not 7 hours :?

Comments

  • You are mixing up roundtrip-time and the timestamp?
    Roundtrip time should be less than 300ms. This is a value per peer (don't know exactly how it's named in the server side).
    The timestamp is the same as Environment.TickCount and goes up all the time until there is a overflow, which makes the value negative. Still that value is good to measure time differences in ms (with ~15ms accuracy only but cheap).
  • There should also be getServerTimeOffset(). That one gives you the difference between server time and client time. Both, getServerTime(), which gives you the absolute serverside time and getServerTimeOffset() are there to offer you an authority on the time, when a client for example sends something like "do that action seconds in the futuer from the point of ime, when I have triggered it", as the receiving clients local time could differ by relevant amounts from the one of the sending client.

    For measuring the delay of messages, you should either use getRoundTripTime(), which basically is the ping of a Photon command or in case that you need the overall delay of a message on high-level, no matter he low-level details like if parts of it had to be repeated or if it has been split up into several chunks, if it has been hold back in a queue for a while, because a client did not want to sent o receive it immendiately, etc., than you would let the sending client, which for example calls opRaiseEvent(), put the returnValue of getServerTime() into the payload of the event to raise and on the receiving client you would read that value out again and subtract it from the returnValue of getServerTime() at that moment.
    The difference between the both returnvalues of getServerTime() will tell you, how much time has ago the message has been sent.

    The 7 hours by the way is the time, that has passed, since your server has been started modulo aprroximate 49days.
  • There should also be getServerTimeOffset().


    I looked through all the Photon Flash API, but did not find this function, only getServerTime()
  • Could be missing in Flash.
    It's not really needed when you use getServerTime(). The offset is not valuable by itself, cause getServerTime calculates the server's time (using the offset) for you.
Sign In or Register to comment.