How do I immediately detect a local disconnection (before timeout is triggered)?

Hello,

I'm looking for a way to immediately detect when the local client's network connection has been lost. I would like to start handling the scenario before the timeout kicks in. It seems to be that there should be a way to do this but I can't find where this information can be gleaned.

Here's an example. I'm testing with 2 machines. They both connect and join a room. On machine A I quickly toggle the WiFi connection on and off, the connection is lost for less than a second. I wait. After about 10 seconds machine B is told by the server that the other player has disconnected. About 5 seconds after that machine A indicates that it's been disconnected.

I'd like to reconnect machine A right after the WiFi is toggled but I don't know how to detect that in Photon. It seems as though Photon has detected it because it starts a timeout counter. Is there a local event for this or some variable that keeps track of the last time a message was received or something?

Please let me know. Thanks.

Comments

  • Hi,

    One thing you could explore is watching the property PhotonNetwork.networkingPeer.TimestampOfLastSocketReceive

    This value fluctuates every seconds, but when offline, it will freeze, so you could be using this as a way to detect you are offline.

    Bye,

    Jean
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @jeanfabre,

    I cannot find TimestampOfLastSocketReceive in PUN Classic or PUN2.
    Could you help me find it?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited December 2018
    Thanks @jeanfabre,

    Found it, it's in the lib (Photon3Unity3d.dll) level, PhotonPeer.TimestampOfLastSocketReceive.