PUN turn based game - retrieve list of rooms for player

Hi all,

I've been reading through documentation and have some code setup that tries to join a random room, if if cannot find one it creates a new room and the first player is then able to submit their turn.

What I am struggling with is a way to retrieve a list of Rooms / Games that the current player is a participant of. I've created the room with the following options, which I believe means it should stay active for up to 7 days?
       RoomOptions _opt = new RoomOptions();
       _opt.MaxPlayers = 2;
       _opt.PlayerTtl = 7 * 24 * 60 * 60 * 1000;
       _opt.EmptyRoomTtl = 300000;

I'm also using OnRoomListUpdate(), but I never seem to hit this method.

Any advice much appreciated.



  • TobiasTobias admin
    Users can only be active in a single room.

    A user can inactive in multiple rooms but that list is not handled by Photon out of the box. To make an async game, you'd have to store the room state somewhere and you'd need to store a list of rooms per player likewise, so the rooms can be re-joined.
    There is a "is persistent" setting in the Dashboard and you'd use WebHooks to store/load the room state.
    See: https://doc.photonengine.com/en-us/realtime/current/gameplay/web-extensions/webhooks

    There is a lobby type, which can list rooms for a while, even if there are no active players inside: LobbyType.AsyncRandomLobby.

    PUN itself (the PhotonView component especially) is not extremely well suited for asynchronous games, which can be played over many sessions. If you use only Custom Properties and RaiseEvent with the Event Cache, you can rely properly on the state to be stored and loaded.
  • Hi Tobias,

    thanks for the in-depth reply, I appreciate it. that all makes a lot of sense, so I appreciate you taking the time.
  • TobiasTobias admin
    You are welcome :)
  • skrilmpsskrilmps
    edited August 1
    Just to be sure I understand, is it possible to create an asynchronous, turn-based game in Unity using PUN?

    Would it be better to use Photon Realtime, even though I'm working in Unity?
  • Photon Realtime is what PUN 2 uses under the hood.
    Yes, it's probably easier in the long run to not use PUN features for turnbased games. There is usually not a big benefit anyways in that use case.
    You can still use the PUN 2 package as basis, which makes updates easy. Get the package and after each update, simply delete the PhotonUnityNetworking folder. Done. Only Realtime and Chat apis are left.
Sign In or Register to comment.