Can't leave the game room

Options
Mostly it goes OK, but sometimes, clients cannot leave the room after PhotonNetwork.LeaveRoom().
The game is not crashed. It's just stuck.
My understanding is OnLeftRoom is called when PhotonNetwork.LeaveRoom() performs.
I'm not sure if OnLeftRoom is not called or other error occur.

What possibly causes this happening? My code is very simple.
Any comments will be so appreciated.

......
public void ExitRoom() {
//
PhotonNetwork.LeaveRoom();
}
......
void OnLeftRoom() {
SceneManager.LoadScene("AnotherScene");
}

Comments

  • Hi @mhhk88,

    is this PUN Classic or PUN 2?

    To check if OnLeftRoom gets called, you can simply add a Debug.Log call and check if the log appears in the editor's console.
  • mhhk88
    Options
    @Simon I'm using PUN classic (v1.85,,, after this error, I upgraded to 1.91). Unfortunately, this error never come out on me (my Unity editor).
    It happened only when many users played the game together (multi user test abroad).
    Like I said, it happens once in a while. Mostly it is OK.
    I will try your suggestion. But it takes time. Because the next test will be in a week.
    Any possible reasons you ever heard about this? Any reasons that OnLeftRoom not called ?
    I am about to launch this game. so I don't want to change it to PUN2. But if PUN2 is surely a lot better in every respects, I will do that. What do you think?
  • If OnLeftRoom is not called, you might want to check, if the client gets disconnected from Photon. Therefore you can add the void OnConnectionFail(DisconnectCause cause) callback. This one gets called, if something causes the connection to fail after it has been established. If it gets called, you can check the DisconnectCause.

    Please note, that OnLeftRoom won't get called, if you close the application. However it will get called, if you use PhotonNetwork.LeaveRoom() (obviouosly) and PhotonNetwork.Disconnect().
  • mhhk88
    Options
    @Simon I found that some other network games also show the same phenomenon. I guess unexpected disconnection is a common network glitch. Reading your answer, I may not be able to prevent from that happening. I should provide something like countermeasures after it happens. Am I thinking in right way?