Packagecom.smartfoxserver.v2.requests
Classpublic class CreateRoomRequest
InheritanceCreateRoomRequest Inheritance com.smartfoxserver.v2.requests.BaseRequest

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.

View the examples

See also

roomAdd event
roomCreationError event


Public Methods
 MethodDefined By
  
CreateRoomRequest(settings:RoomSettings, autoJoin:Boolean = false, roomToLeave:Room = null)
Creates a new CreateRoomRequest instance.
CreateRoomRequest
Constructor Detail
CreateRoomRequest()Constructor
public function CreateRoomRequest(settings:RoomSettings, autoJoin:Boolean = false, roomToLeave:Room = null)

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

Parameters
settings:RoomSettings — An object containing the Room configuration settings.
 
autoJoin:Boolean (default = false) — If true, the Room is joined as soon as it is created.
 
roomToLeave:Room (default = null) — A Room object representing the Room that should be left if the new Room is auto-joined.

See also

Examples
The following example creates a new chat room:
     
     private function someMethod():void
     {
         sfs.addEventListener(SFSEvent.ROOM_ADD, onRoomCreated);
         sfs.addEventListener(SFSEvent.ROOM_CREATION_ERROR, onRoomCreationError);
         
         // Create a new chat Room
         var settings:RoomSettings = new RoomSettings("My Chat Room");
         settings.maxUsers = 40;
         settings.groupId = "chats";
         
         sfs.send(new CreateRoomRequest(settings));
     }
     
     private function onRoomCreated(evt:SFSEvent):void
     {
         trace("Room created: " + evt.params.room);
     }
     
     private function onRoomCreationError(evt:SFSEvent):void
     {
         trace("Room creation failed: " + evt.params.errorMessage);
     }