Detect player timeout

Hi there,

Is it possible to detect if a connected player has stopped sending and receiving messages? I'm working on a multiplayer RTS and I want to pause the game if a player has stopped responding. I realize I could use RPCs but this would be quite inefficient and would create unnecessary traffic if I'm correct...?

Thanks

Comments

  • I'm not a Photon expert, but i think you can't know without sendind RPC to check .

    You can use the master Client to send RPC every X second to specific client (With photon ID) , and wait for a anwser by RPC.

    Use logic, imagine you can detect that a player don't move since 10 second. Send to him a RPC and wait for awnser.
    (Sorry for my english ^^ )
  • Hi @SamShiels,

    difficult question. When you have frequent movement in your game, you will notice another client's timeout, when the client's character suddenly stops moving around. This would be also possible to detect in code. Also when using the OnPhotonSerializeView function for synchronization, you can also store the timestamp of the last received message which allows you to check if the client is still sending something. However this is not an accurate solution. If the client's character isn't moving around for example, you are not able to say, if he has a timeout or is just not moving. If he isn't moving, OnPhotonSerializeView also won't send new messages.

    The only reliable option you have, is to check the void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer) callback. Whenever this one is called, you know that a certain client is disconnected from the room. The reason for this is either, that the client leaves the room or gets disconnected by a timeout for example. If you allow rejoining. this callback might not get called (depends on the settings made within the RoomOptions). In this case you want to have a look at the void OnPhotonPlayerActivityChanged(PhotonPlayer otherPlayer) callback. This one gets called whenever the activity of a client changes, for example when a client becomes inactive.