new CreateRoomRequest(settings[, autoJoin][, roomToLeave])

Creates a new CreateRoomRequest instance. The instance must be passed to the SmartFox.send() method for the request to be executed.

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.

Example

This 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.RoomSettings("My Chat Room");
	settings.maxUsers = 40;
	settings.groupId = "chats";

	sfs.send(new SFS2X.CreateRoomRequest(settings));
}

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

function onRoomCreationError(evtParams)
{
	console.log("Room creation failed: " + evtParams.errorMessage);
}

Parameters

Name Type Optional Description

settings

 

 

An object containing the Room configuration settings.

autoJoin

 

Yes

If true, the Room is joined as soon as it is created.

Defaults to false.

roomToLeave

 

Yes

A SFSRoom object representing the Room that should be left if the new Room is auto-joined.

Defaults to null.

See also
SmartFox#send
RoomSettings
MMORoomSettings
SFSRoom
MMORoom
SFSEvent.ROOM_ADD
SFSEvent.ROOM_CREATION_ERROR