Packagecom.smartfoxserver.v2.requests
Classpublic class ChangeRoomCapacityRequest
InheritanceChangeRoomCapacityRequest Inheritance com.smartfoxserver.v2.requests.BaseRequest

Changes the maximum number of users and/or spectators who can join a Room.

If the operation is successful, the roomCapacityChange event is dispatched to all the users who subscribed the Group to which the target Room belongs, including the requester user himself. If the user is not the creator (owner) of the Room, the roomCapacityChangeError event is fired. An administrator or moderator can override this constrain (he is not requested to be the Room's owner).

Please note that some limitations are applied to the passed values (i.e. a client can't set the max users to more than 200, or the max spectators to more than 32). Also, if the Room was configured so that resizing is not allowed (see the RoomSettings.permissions parameter), the request is ignored and no error is fired.

In case the Room's capacity is reduced to a value less than the current number of users/spectators inside the Room, exceeding users are NOT disconnected.

View the examples

See also

roomCapacityChange event
roomCapacityChangeError event
RoomSettings.permissions


Public Methods
 MethodDefined By
  
ChangeRoomCapacityRequest(room:Room, newMaxUsers:int, newMaxSpect:int)
Creates a new ChangeRoomCapacityRequest instance.
ChangeRoomCapacityRequest
Constructor Detail
ChangeRoomCapacityRequest()Constructor
public function ChangeRoomCapacityRequest(room:Room, newMaxUsers:int, newMaxSpect:int)

Creates a new ChangeRoomCapacityRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Parameters
room:Room — The Room object corresponding to the Room whose capacity should be changed.
 
newMaxUsers:int — The new maximum number of users/players who can join the Room.
 
newMaxSpect:int — The new maximum number of spectators who can join the Room (for Game Rooms only).

See also

Examples
The following example changes the capacity of an existing Room:
     
     private function someMethod():void
     {
         sfs.addEventListener(SFSEvent.ROOM_CAPACITY_CHANGE, onRoomCapacityChanged);
         sfs.addEventListener(SFSEvent.ROOM_CAPACITY_CHANGE_ERROR, onRoomCapacityChangeError);
         
         var theRoom:Room = sfs.getRoomByName("Gonzo's Room");
         
         // Resize the Room so that it allows a maximum of 100 users and zero spectators
         sfs.send(new ChangeRoomCapacityRequest(theRoom, 100, 0));
     }
     
     private function onRoomCapacityChanged(evt:SFSEvent):void
     {
         trace("The capacity of Room " + evt.params.room.name + " was changed successfully");
     }
     
     private function onRoomCapacityChangeError(evt:SFSEvent):void
     {
         trace("Room capacity change failed: " + evt.params.errorMessage);
     }