Leaves one of the Rooms joined by the current user.

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

Syntax

C#
public class LeaveRoomRequest : BaseRequest

Remarks

Depending on the Room configuration defined upon its creation (see the RoomSettings.Events setting), when the current user leaves it, the following events might be fired: USER_EXIT_ROOM, dispatched to all the users inside the Room (including the current user then) to warn them that a user has gone away; 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.

Examples

The following example makes the user leave the currently joined Room and handles the respective event:
 Copy imageCopy
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
    // Leave the last joined Room
    sfs.Send( new LeaveRoomRequest() );
}
void OnUserExitRoom(BaseEvent evt) {
    User user = (User)evt.Params["user"];
    Room room = (Room)evt.Params["room"];
    Console.WriteLine(""User " + user.Name + " just left Room " + room.Name);                       // .Net / Unity
    System.Diagnostics.Debug.WriteLine(""User " + user.Name + " just left Room " + room.Name);      // Windows Universal
}

Inheritance Hierarchy

System..::..Object
  BaseRequest
    Sfs2X.Requests..::..LeaveRoomRequest

See Also