Class SFS2X.Requests.System.ChangeRoomCapacityRequest

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

Class Summary
Constructor Attributes Constructor Name and Description
 
SFS2X.Requests.System.ChangeRoomCapacityRequest(room, newMaxUsers, newMaxSpect)
Creates a new ChangeRoomCapacityRequest instance.

Class Detail

SFS2X.Requests.System.ChangeRoomCapacityRequest(room, newMaxUsers, newMaxSpect)
Creates a new ChangeRoomCapacityRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

This request 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, or if the Room was configured so that capacity changing is not allowed (see the RoomSettings.permissions parameter), the roomCapacityChangeError 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:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE, onRoomCapacityChanged, this);
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE_ERROR, onRoomCapacityChangeError, this);
	
	var theRoom = sfs.getRoomByName("Gonzo's Room");
	
	// Resize the Room so that it allows a maximum of 100 users and zero spectators
	sfs.send(new SFS2X.Requests.System.ChangeRoomCapacityRequest(theRoom, 100, 0));
}

function onRoomCapacityChanged(evtParams)
{
	console.log("The capacity of Room " + evtParams.room.name + " was changed successfully");
}

function onRoomCapacityChangeError(evtParams)
{
	console.log("Room capacity change failed: " + evtParams.errorMessage);
}
Parameters:
{SFSRoom} room
The Room object corresponding to the Room whose capacity should be changed.
{Number} newMaxUsers
The new maximum number of users/players who can join the Room; the -1 value can be passed not to change the Room.maxUsers property.
{Number} newMaxSpect
The new maximum number of spectators who can join the Room (for Game Rooms only); the -1 value can be passed not to change the Room.maxSpectators property.
See also:
SFS2X.SmartFox#send
SFS2X.Entities.SFSRoom#maxUsers
SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE
SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE_ERROR