Class SFS2X.Requests.System.CreateRoomRequest

Creates a new Room in the current Zone.

Class Summary
Constructor Attributes Constructor Name and Description
 
SFS2X.Requests.System.CreateRoomRequest(settings, autoJoin, roomToLeave)
Creates a new CreateRoomRequest instance.

Class Detail

SFS2X.Requests.System.CreateRoomRequest(settings, autoJoin, roomToLeave)
Creates a new CreateRoomRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

This request creates a new Room in the current Zone. If the creation is successful, a roomAdd event is dispatched to all the users who subscribed the Group to which the Room is associated, including the Room creator. Otherwise, a roomCreationError event is returned to the creator's client.

The following example creates a new chat Room:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_ADD, onRoomCreated, this);
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_CREATION_ERROR, onRoomCreationError, this);
	
	// Create a new chat Room
	var settings = new SFS2X.Requests.RoomSettings("My Chat Room");
	settings.maxUsers = 40;
	settings.groupId = "chats";
	
	sfs.send(new SFS2X.Requests.System.CreateRoomRequest(settings));
}

function onRoomCreated(evtParams)
{
	console.log("Room created: " + evtParams.room);
}

function onRoomCreationError(evtParams)
{
	console.log("Room creation failed: " + evtParams.errorMessage);
}
Parameters:
{RoomSettings} settings
An object containing the Room configuration settings.
{Boolean} autoJoin Optional, Default: false
If true, the Room is joined as soon as it is created.
{SFSRoom} roomToLeave Optional, Default: null
A SFSRoom object representing the Room that should be left if the new Room is auto-joined.
See also:
SFS2X.SmartFox#send
SFS2X.Requests.RoomSettings
SFS2X.Requests.MMO.MMORoomSettings
SFS2X.Entities.SFSRoom
SFS2X.Entities.MMORoom
SFS2X.SFSEvent.ROOM_ADD
SFS2X.SFSEvent.ROOM_CREATION_ERROR