Rejoin on a different device

edited March 2022 in Photon Server

Hello !

I want to be able to reconnect into a room from a different device if my first device is disconnected (run out of battery on my phone, so want to reconnect on my computer), I assume that the 2 devices will connect using the same account and then have the same userID and playerTTL is high.

From what i understood of rejoin, it can be done easily inside the same running instance of the game using reconnectAndRejoin, but RejoinRoom need the name of the room, that can be save on my first device, but that is not available on my second device.

There is a findFriend feature, but this does not allow me to get the room of the current player, only other players. As the masterServer has the list of room available and the userIDs save as inactive player, I expect to get this information from server side and not doing any computation on client side to get it, but maybe I'm wrong.

Is there any way to achieve this with a simple query to server side (similar to findFriend but for current player). Else, is there anything that can be done in client side to get it ? (I want to avoid publishing the userID of room, and let client loop over all rooms to find its own.)

Hope I am clear enough for you to help me on that ;)

Edit1: Did not mention I'm running an on-premise plugin server, so I wonder if there is anything that can be setup on server side in order to get this information, if not possible from client.


  • Out of the box, our servers don't support fetching your own "current room name".

    As you already mentioned, you need userIDs and authentication. Then the same user can connect from another device. If said user is still not timed out (on the server side) from the room (so PlayerTTL did not yet start), you can't rejoin the room (yet) as there is an active connection (and the client has another auth token). Here, I would just assume that players need a few seconds to switch devices and login, so waiting some more seconds for the timeout to happen for the original connection is a non-issue in my opinion. Use ReJoinRoom with the room name fetched somewhere.

    An easy way would be to use a web service to which the plugin reports joins (so the service knows the user's room and region, etc), then the clients can ask this service.

    Alternatively the Master Server needs some modifications to cache the room per userId for X seconds longer than the user is in a room (the GS sends userIDs to the Master Server already, which is why FindFriends works). You'd implement FindMe, basically. The key is: You need to cache this longer than the user is online but clean up.

    Don't send the room list to the clients to search for your own room. I don't recall if the user is even listed during the PlayerTTL timing out. It scales horribly.

    Hope that helps.

  • Thank you, your answer helps a lot.

    When you say "Alternatively the Master Server needs some modifications", is there a way do modifications on the master server using the plugin SDK ? I didn't find anything about it.

  • JohnTube
    JohnTube ✭✭✭✭✭

    Hi @BatTotoro,

    Thank you for choosing Photon!

    Photon Server Plugins SDK is for Game Server plugins only.

    But since you are self-hosting you can modify actual LoadBalancing app server code, master application code as @Tobias suggested.

  • Thanks a lot, I was not aware that photon plugin SDK and photon server SDK are fully compatible.

    I will check there so.