best way to check other player to disconnect?

in many pausing case, client can disconnect by him self, so there is no problem
but if client lost internet connection, he can't send anything to server and PhotonNetwork.CloseConnection( player ) function is not working to this client ( i tested this is only working for online player in room)
PUN cloud server will kick after 10 second automatically. but i want to kick him in 1~2 second

so i used this way
1. every player set their "ping" and "ping set time" in every second ( using player property, set PhotonNetwork.time )
2. every player check how long time passed after another player set their ping ( with "ping set time" )
3. if another player's "ping set time" is longer than 2~3 second than PhotonNetwork.time, then diable his gameobject (used disable because CloseConnection function not working for offline user )
4. in 3 step if he is a masterclient, change masterclient to other

but this way need to using many msg.
( there is 500 msg / s per room! )

so i want to know best way to check player timeout by other!

Comments

  • Hi,

    I'll check that value you can watch for players on stream updates, you should definitly avoid waisting events for this.

    Bye

    Jean
  • jeanfabre said:

    Hi,

    I'll check that value you can watch for players on stream updates, you should definitly avoid waisting events for this.

    Bye

    Jean

    thank you i'll waiting your reply!
  • i aksed it to other but they didnt know about it

    omg!
  • Hi,

    ok, I don't think there are any variables easily available to know about this.

    I haven't experimented on this yet, but I would assume that if you implement serialization yourself, then when you are reading, you could maintain a timer since the last time you deserialized, and if it goes more than 2 or 3 seconds that means the owner is not sending anything and is likely disconnected. It could varies depending on how you've setup your observe options but that would be something to experiment.

    Bye,

    Jean
  • jeanfabre said:

    Hi,

    ok, I don't think there are any variables easily available to know about this.

    I haven't experimented on this yet, but I would assume that if you implement serialization yourself, then when you are reading, you could maintain a timer since the last time you deserialized, and if it goes more than 2 or 3 seconds that means the owner is not sending anything and is likely disconnected. It could varies depending on how you've setup your observe options but that would be something to experiment.

    Bye,

    Jean

    ok thank you too reply
  • jokerTMjokerTM
    edited July 10
    Best way to check is when RPC from photon view is called , use PhotonNetwork.networkingPeer.SendOutGoingCommands(); to send 1 last packet in RPC and lose focus.
    void OnApplicationPause(bool pauseStatus)
        {
            isPaused = pauseStatus;
            
            photonView.RPC("Reciver", PhotonTargets.All, pauseStatus);
    
            PhotonNetwork.networkingPeer.SendOutgoingCommands();
    
            Debug.Log("Pause Firing");
        }
Sign In or Register to comment.