Creates a new Room in the current Zone.

Namespace: Sfs2X.Requests
Assembly: SmartFox2X (in SmartFox2X.dll) Version: (1.7.3)


public class CreateRoomRequest : BaseRequest


If the creation is successful, a ROOM_ADD event is dispatched to all the users who subscribed the Group to which the Room is associated, including the Room creator. Otherwise, a ROOM_CREATION_ERROR event is returned to the creator's client.


The following example creates a new chat room:
 Copy imageCopy
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.ROOM_ADDED, OnRoomAdded);
    sfs.AddEventListener(SFSEvent.ROOM_CREATION_ERROR, OnRoomCreationError);
    // Create a new Chat Room
    RoomSettings settings = new RoomSettings("My Chat Room");
    settings.MaxUsers = 40;
    settings.GroupId = "chats";
    sfs.Send( new CreateRoomRequest(settings) );
void OnRoomAdded(BaseEvent evt) {
    Console.WriteLine("Room created: " + (Room)evt.Params["room"]);                         // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Room created: " + (Room)evt.Params["room"]);        // Windows Universal
void OnRoomCreationError(BaseEvent evt) {
    Console.WriteLine("Room creation failed: " + (string)evt.Params["errorMessage"]);                       // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Room creation failed: " + (string)evt.Params["errorMessage"]);      // Windows Universal

Inheritance Hierarchy


See Also