Max players

edited February 2011 in Photon Server
Hi, I`m learning photon server with unity3d client. I have few questions.
1. How to set player limit per room. Like 16 or 32 for FirstPersonShooter.
2. What happens when no players left in the room. The room will be automaticly destroyed on the server?

Comments

  • 1. To ensure that not too many clients are joining you would have to override the HandleJoinOperation method and check the current player count. Return an error if the game is full.
    2. yes: dispose is called when releasing the last room reference (RoomCacheBase.ReleaseRoomReference)
  • How do you get the count of players from the overridden operation?
  • I see two options:

    1)
    LiteGame.HandleJoinOperation:
    this.Actors.Count
    

    2)
    Look at RoomCacheBase.ReleaseRoomReference, there is a check if the room is empty:
    if (roomInstance.ReferenceCount <= 0)
    
    You could check if the room is full in RoomCacheBase.GetRoomReference the same way.
  • Thanks, I was able to accomplish what I needed to do with the suggestions.
Sign In or Register to comment.