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.0)


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, or if the Room was configured so that capacity changing is not allowed (see the RoomSettings.Permissions parameter), the ROOM_CAPACITY_CHANGE_ERROR event if fired. An administrator or moderator can override the first constrain (he is not requested to be the Room's owner).

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