MasterClient detect if client killed the android app

Hi,

When a client disconnects, on the client side, I`m calling OnConnectionFail(DisconnectCause cause). If the cause is a timeout because of a bad connection, I use ReconnectAndRejoin () and he comes back to game. All is working fine.

Now I`m trying to handle the situation when a player intentionally leaves the game. I ll create a Quit button that will send a msg to Master saying that he is leaving for real. So the Master will do its job.

My doubt is when the player kills the app...
Is there something like OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer, DisconnectCause cause) on the Master side?
The Master handle a remote client killing the app as a timeout?
Can the client send a msg to the Master in the moment it gets killed?

Thanks a lot!

Comments

  • Hi @Cabjhegas,

    void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer) is called on each client who is still in the room. So you can use this one to notify the MasterClient that a certain client has left the game. I think there is no need to send an additional message.

    If the application gets closed, the client will automatically disconnects from Photon which results in the OnPhotonPlayerDisconnected call on all other clients.
  • Thank you Simon.

    But is OnPhotonPlayerDisconnected called when a player get disconnected by timeout (even if he is still able to get back to room by a ReconnectAndRejoin) ?

    I'm asking because I need different behaviour for both cases. If a player get disconnected by timeout, the game will wait for him to rejoin the room. If he leaves definitly, it will get killed immediately.
  • Are you using RoomOptions.PlayerTtl with a value larger than 0 when creating the room? In this case OnPhotonPlayerDisconnected is only called when the client gets removed from the server's cache, after the value for PlayerTtl has expired. It doesn't matter if the client got disconnected by network issues, closing the application or leaving the room regularly.

    Also when PlayerTtl is set and the server notices that one client is not present any longer (e.g. network interruption), this player is marked as inactive. You can monitor this state by implementing the void OnPhotonPlayerActivityChanged(PhotonPlayer otherPlayer) callback. As soon as one player is inactive, you can wait for him to rejoin. If he comes back, you can continue the game - if OnPhotonPlayerDisconnected gets called, you can continue the game without him (or do whatever is necessary in this case).
  • Yes, I`m using PlayerTtl = -1;
    It`s a turn based game that a player could put the game on background for a long time until it is his turn again.
    You cleared the things up for me. I decided the way to go. Thanks
  • I got a diferente problem now. I reallized that a player cannot be kicked right?
    So I was think if I can create my room with PlayerTtl = 0 (so, in my Looby scene, reconnection is not an option and inactive players would not be in the room); and as soon as the Master choose to start the Game, when the Game Scene load, I change the PlayerTtl to -1 allowing reconnection. Is this possible?

    Should I create another topic for this?

    Thanks
  • Is this possible?
    Yes it is now possible to change PlayerTTL and EmptyRoomTTL post room creation.

    Should I create another topic for this?
    Please do next time or if you still have further questions related to this.
Sign In or Register to comment.