Rejoin old room after Application Quit

My game uses a room list. (room name, clients, ping etc. can be displayed there)

The player joins a prefered room from the room list (All rooms have got EmptyRoomTtl value of 0)
When the room is full
1. It becomes closed (PhotonNetwork.CurrentRoom.IsOpen = false;)
2. The PlayerTtl changes from 0 to 300000 "5 minutes".
3. A new level is loaded for all the players in this room.

After the new level is loaded when a player leaves this room I give him the choice to either rejoin back or not by popping up a reconnect window.
I store the name of the room the player joins so I can use the RejoinRoom(string roomName) method.

As my roomlist keeps it self updated using the OnRoomListUpdate() callback it is easy to identify whether I can rejoin a room or not. But this is much harder when the application quitted because I miss some OnRoomListUpdate() callbacks.

The issue I have is when the player leaves the room and quits his application (or crashes somehow) there is no way I can identify whether the roomName I have stored can still be used. The room it refers too may:
1. have been disbanded.
2. have been disbanded and a new player created a room by the same name.
3. stills unchanged.

This results in the reconnect window to popup in all 3 scenarios and the player has to click 'Rejoin' and execute the actual RejoinRoom(string roomName) method in order to identify whether he can still rejoin that room.

Already tried to use roomCustomProperties to store the time the room was created so I can somehow compare it with the current time but time is different for each area of the region and PhotonNetwork.Time doesn't seem to work that way (it is not a datetime).
Any ideas?

Comments

  • Hi @ivtec_civic,

    Thank you for choosing Photon!

    The best way to handle this is to have rooms list per user on your custom web based backend.
    To track the list of rooms joined by a user and that can be rejoined, you need to make use of Webhooks.
    To get the list of rooms on app start either use WebRPC or client to server HTTP requests.

    If you don't want to do this, simply cache the room name and handle the rejoin errors.
    I don't see a way to avoid those without making the actual rejoin room attempt.
    It's up to you how you deal with this in the UI.

    A trick maybe: You could do a silent automatic rejoin attempt of last joined room in the background as soon as the app starts. This way you would know the outcome beforehand and you could hide or show the "rejoin" button.
  • ivtec_civic
    edited June 5
    hello, thanks for your reply.
    I tried to solve my reconnect issue by adding a 'hidden' GUID at the room name so everytime a new room is created its name is globally unique and everytime the player checks whether the room he cached is available it is 100% sure that he refers to the same room he played in.
    BUT!
    when I exit the application and reopen it again I ask to join the same room using the RejoinRoom() method it gives me an error "User does not exist in this game"
    This looks like the PhotonRealtimePlayer assigned to my client the 2nd time I open the application is different from the old one.
    So, is it completely impossible to rejoin the same room after reopening the application?
  • Hi @ivtec_civic,

    To be able to rejoin rooms with the same actor number (PlayerTTL != 0) you need to keep the same UserId.
    So make sure you use the same UserId when you reconnect.
    Either cache it locally on device as you cache the room name OR make use of custom authentication provider or "device unique hardware ID".
    Read here about setting UserId before connecting and authentication.
  • Perfect! that's all I needed!
    I managed to reconnect after the application quitted thanks!