How to detect if other player is Reconnecting?

Options
Hello !
I made a game with 2 players in a room. I create room and set the PlayerTtl = 10000, EmptyRoomTtl = 10000.
Let's say player A and B are playing. When player B disconnected, player B will try to reconnect to the game while player A can't do anything and have to wait for player B. The problem is i can't detect that player B is reconnecting at the time he disconnects. When player B is disconnected for 10s i can detect it from OnPhotonPlayerDisconnected(). How can i detect the first time it is disconnected and trying to reconnect?
Someone please help.
@Christian_Simon

Comments

  • Hi @liorium,

    you can try to use the void OnPhotonPlayerActivityChanged(PhotonPlayer otherPlayer) callback. It gets called when a player becomes (in-)active. This way you would know, if a player reconnected to the room.
  • liorium
    liorium
    edited September 2018
    Options
    Hi @Christian_Simon

    Thanks for your answer.
    I tried to use void OnPhotonPlayerActivityChanged(PhotonPlayer otherPlayer) callback and check if the player IsInActive but it gets called around 5 secs after the otherplayer loses connection. Is it because of the PhotonNetwork.DisconnectTimeOut set to 5000 ? I read it in the forum if i set the value too low, slow connection can be considered the player is disconnected.
    Is there a way for me to immediately gets the callback after the player loses connection?
  • IsInActive but it gets called around 5 secs after the otherplayer loses connection. Is it because of the PhotonNetwork.DisconnectTimeOut set to 5000 ? I read it in the forum if i set the value too low, slow connection can be considered the player is disconnected.


    Yes, that's right. If you set this value too low, some client might get problems with keeping the connection alive.

    Is there a way for me to immediately gets the callback after the player loses connection?


    No, because the server doesn't know either. The server is the one who informs all clients about the activity change. If the server doesn't get any message from the client, he will either change the client's activity state or removes him from the room after a certain amount of time. This depends on the settings made with PlayerTtl, too.
  • liorium
    Options
    Okay thanks for your answer @Christian_Simon