How to kick inactive player

Lele
Lele

Hi, I would like to disconnect a player instantly as he presses the smartphone's home button or puts the app in the background (Photon Cloud PUN).

I tried with:

OnApplicationFocus(bool focus)

and

PhotonNetwork.NetworkingClient.LoadBalancingPeer.DisconnectTimeout = 0;

But none of these would seem to work. Could you help me?

Thanks.

Best Answer

  • Tobias
    Tobias admin
    Answer ✓

    OnApplicationFocus sounds good but you may want to call PhotonNetwork.Disconnect() instead of setting some timeout.

Answers

  • Tobias
    Tobias admin
    Answer ✓

    OnApplicationFocus sounds good but you may want to call PhotonNetwork.Disconnect() instead of setting some timeout.

  • ihor
    ihor
    edited June 2022

    Please call

    PhotonNetwork.Disconnect();

    instead of

    PhotonNetwork.NetworkingClient.LoadBalancingPeer.DisconnectTimeout = 0;

    And this will be okay.