How can I check I can rejoin my previous room

Options
I am using PUN classic v1.98.
For a max 2 player room, after a player quit the application, he can rejoin the room by
PhotonNetwork.ReJoinRoom(getLastRoom()));

However, how can I notice player whether he can rejoin the previous room?
I tried
RoomInfo[] rooms = PhotonNetwork.GetRoomList();

		for (int i = 0; i < rooms.Length; i++)
		{
			if (rooms[i].Name == getLastRoom())
			{
				Debug.Log("LastRoom exists !");
				break;
			}
		}
when I join the lobby again to get the room list but the list always empty.
I have already checked "Enable Lobby Stats" in setting.

How can I solve it?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @DarrenL,

    Use PhotonNetwork.ReconnectAndRejoin() and check return value if you recover form unexpected disconnect or the app was in background.
    or PhotonNetwork.RejoinRoom() and implemnt OnPhotonJoinRoomFailed callback to catch an error.
    So the approach should be optimistic: try to rejoin and see if it succeeds.

    You need to have the same UserId when rejoining and PlayerTTL should not be 0, either -1 or a value high enough in milliseconds to allow time for rejoining.
    Empty rooms are deleted on Photon Cloud after EmptyRoomTTL milliseconds which has a maximum value of 300000 ms.
    If you want to save and load room states you could use Photon Webhooks.