Click or drag to resize

LeaveRoomRequest Class

Leaves one of the Rooms joined by the current user.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.RequestsLeaveRoomRequest

Namespace:  Sfs2X.Requests
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public class LeaveRoomRequest : BaseRequest
Constructors
  NameDescription
Public methodLeaveRoomRequest
See LeaveRoomRequest(Room) constructor.
Public methodLeaveRoomRequest(Room)
Creates a new LeaveRoomRequest instance.
Top
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:
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);      // UWP
}
See Also