Turnbased across several rooms simultaneously

Is it possible to be logged on several rooms? Im making a turn based chess and playing several games at the same time is a must feature. Thanks.


  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Yohami,

    It is not possible for a Photon client to be joined to more than one room at the same time.
    You just need to switch between rooms.
  • Yohami
    edited November 2015
    But can it switch between rooms to resume several concurrent games? or will the switch make him "leave the game" and destroy his player?
  • JohnTube
    JohnTube ✭✭✭✭✭
    In Photon TurnBased players can leave rooms without abandoning it. The corresponding actor will not be removed from the room and it will be marked as "inactive" until the player rejoins the room (actor becomes "active" again) or until PlayerTTL.

    However, you need to handle saving and loading room states on your own in case rooms may stay empty (all players left) for a while. If that's the case, you should start looking into webhooks.
  • Thanks John
  • Is webhook state management only necessary if players will be out of the room for longer than PlayerTtl? Or only longer than EmptyRoomTtl? Basically, what's the max amount of time I can expect the state of the room to be maintained by Photon without webhooks when both players are not connected to the room?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited March 2016
    PlayerTTL is how long a player can stay inactive (i.e. disconnected from the room). Negative value means a player can stay in the room forever. Max integer value can have similar behavior. It can be useful for 2 cases:
    • A player that gets unexpected disconnection can rejoin as long as the room is still alive.
    • You want to save room state for players to pause and return to the game later.
    EmptyRoomTTL is how long a room state can remain in Photon server memory when all players become inactive. It is useful in case you want a player to join/rejoin during that period.
    EmptyRoomTTL is useful only when PlayerTTL != 0. Max EmptyRoomTTL for Photon Cloud is 300000 ms (5 minutes).

  • Good to know that PlayerTtl supersedes EmptyRoomTtl. That explains why I've seen EmptyRoomTtl set to 0 in some examples. My goal is to have a room exist and persist for 7 days after all players become inactive.

    However, currently, any rooms I create disappear within seconds after I leave them (with inactive set to true and with PlayerTtl set to a week). What could I be doing wrong?
  • richjoslin
    edited April 2016
    The PlayerTtl versus EmptyRoomTtl difference and actual meaning was a huge breakthrough. My rooms were disappearing because my EmptyRoomTtl was set to either zero, or just a few seconds. PlayerTtl is ignored completely, or I still don't understand its use - maybe it's only used in Webhooks? I don't know. Any documentation someone can point me to on that would be great. I've searched and searched. Update: I found more info on PlayerTtl, and it does not control how long a room persists. This could be made clearer in examples/tutorials/etc.

    I've got a longer rant about this, but I've also got a Photonian email thread going, so I'm going to post it there. In a nutshell: the Turnbased intro page is misleading in how it portrays room state persistence, e.g. "Players can leave a game and continue at any time - the state is persisted for them." It explains Webhooks but does not tie room persistence exclusively to them.