Click or drag to resize

ChangeRoomCapacityRequest Class

Changes the maximum number of users and/or spectators who can join a Room.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.RequestsChangeRoomCapacityRequest

Namespace:  Sfs2X.Requests
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public class ChangeRoomCapacityRequest : BaseRequest

The ChangeRoomCapacityRequest type exposes the following members.

Constructors
  NameDescription
Public methodChangeRoomCapacityRequest
Creates a new ChangeRoomCapacityRequest instance.
Top
Remarks
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.

Examples
The following example changes the capacity of an existing Room:
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");      // UWP
}

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"]);       // UWP
}
See Also