Ability to reconnect to the same room after application had been closed and reopened

Options
Hello. So, the question is whether it is possible to connect to the room player had left before closing application.

I tried to use PhotonNetwork.Reconnect(); method but it says that current user had not been connected.
I also tried setting PhotonNetwork.AuthValues.UserId to UserId player had before closing the app.

So, is there a way to "tell" photon that I am the one who had been playing in this room a minute ago (before application closed)?

PhotonNetwork.ReconnectAndRejoin(); method works fine when application state had been switched from background to foreground but seems useless in my case.

Thanks in advance!

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @DIN,

    Depending on your game logic there are two ways to do this:
    1. cache the room name locally, e.g. save it to a file: when you join a room save its name to the file, when you leave it or the room is gone clear that file. when you open the app, read that file and get the room name if any. If there is a room name try to rejoin it if possible (if the room still exists server-side or its state can be restored/loaded using webhooks).
    2. keep a joined rooms list server side, e.g. using webhooks and webRPCs: when a player joins a room add an entry to his/her open/active/ongoing games list using webhooks or other means on your web server or third party web service. when the player leaves the room, clear that entry. when you open the app or connect to master server, get the list of rooms from web server.