Joins the current user in a Room.

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


public class JoinRoomRequest : BaseRequest


If the operation is successful, the current user receives a ROOM_JOIN event; otherwise the ROOM_JOIN_ERROR event is fired. This usually happens when the Room is full, or the password is wrong in case of password protected Rooms.

Depending on the Room configuration defined upon its creation (see the RoomSettings.Events setting), when the current user joins it, the following events might be fired: USER_ENTER_ROOM, dispatched to the other users inside the Room to warn them that a new user has arrived; USER_COUNT_CHANGE, dispatched to all clients which subscribed the Group to which the Room belongs, to update the count of users inside the Room.


The following example makes the user join an existing Room:
 Copy imageCopy
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom);
    sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnJoinRoomError);
    // Join a Room called "Lobby"
    sfs.Send( new JoinRoomRequest("Lobby") );
void OnJoinRoom(BaseEvent evt) {
    Console.WriteLine("Room joined successfully: " + (Room)evt.Params["room"]);                         // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Room joined successfully: " + (Room)evt.Params["room"]);        // Windows Universal
void OnJoinRoomError(BaseEvent evt) {
    Console.WriteLine("Room joining failed: " + (string)evt.Params["errorMessage"]);                        // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Room joining failed: " + (string)evt.Params["errorMessage"]);       // Windows Universal

Inheritance Hierarchy


See Also