Click or drag to resize

CreateRoomRequest Class

Creates a new Room in the current Zone.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.RequestsCreateRoomRequest

Namespace:  Sfs2X.Requests
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public class CreateRoomRequest : BaseRequest
Constructors
  NameDescription
Public methodCreateRoomRequest(RoomSettings)
See CreateRoomRequest(RoomSettings, bool, Room) constructor.
Public methodCreateRoomRequest(RoomSettings, Boolean)
See CreateRoomRequest(RoomSettings, bool, Room) constructor.
Public methodCreateRoomRequest(RoomSettings, Boolean, Room)
Creates a new CreateRoomRequest instance.
Top
Remarks
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.
Examples
The following example creates a new chat room:
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"]);        // UWP
}

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"]);      // UWP
}
See Also