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

Namespace: Sfs2X.Requests
Assembly: SmartFox2X (in SmartFox2X.dll) Version: (1.7.3)


public class ChangeRoomCapacityRequest : BaseRequest


If the operation is successful, the ROOM_CAPACITY_CHANGE 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 ROOM_CAPACITY_CHANGE_ERROR 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).
Alos, 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.


The following example changes the capacity of an existing Room:
 Copy imageCopy
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.ROOM_CAPACITY_CHANGE, OnRoomCapacityChange);
    sfs.AddEventListener(SFSEvent.ROOM_CAPACITY_CHANGE_ERROR, OnRoomCapacityChangeError);
    Room theRoom = 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) );
void OnRoomCapacityChange(BaseEvent evt) {
    Room room = (Room)evt.Params["room"];
    Console.WriteLine("The capacity of Room " + room.Name + " was changed successfully");                       // .Net / Unity
    System.Diagnostics.Debug.WriteLine("The capacity of Room " + room.Name + " was changed successfully");      // Windows Universal
void OnRoomCapacityChangeError(BaseEvent evt) {
    Console.WriteLine("Room capacity change failed: " + (string)evt.Params["errorMessage"]);                        // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Room capacity change failed: " + (string)evt.Params["errorMessage"]);       // Windows Universal

Inheritance Hierarchy


See Also