Packagecom.smartfoxserver.v2.requests
Classpublic class LeaveRoomRequest
InheritanceLeaveRoomRequest Inheritance com.smartfoxserver.v2.requests.BaseRequest

Leaves one of the Rooms joined by the current user.

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: userExitRoom, dispatched to all the users inside the Room (including the current user then) to warn them that a user has gone away; userCountChange, dispatched to all clients which subscribed the Group to which the Room belongs, to update the count of users inside the Room.

View the examples

See also

userExitRoom event
userCountChange event
RoomSettings.events


Public Methods
 MethodDefined By
  
LeaveRoomRequest(theRoom:Room = null)
Creates a new LeaveRoomRequest instance.
LeaveRoomRequest
Constructor Detail
LeaveRoomRequest()Constructor
public function LeaveRoomRequest(theRoom:Room = null)

Creates a new LeaveRoomRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Parameters
theRoom:Room (default = null) — The Room object corresponding to the Room that the current user must leave. If null, the last Room joined by the user is left.

See also

Examples
The following example makes the user leave the currently joined Room and handles the respective event:
     
     private function someMethod():void
     {
         sfs.addEventListener(SFSEvent.USER_EXIT_ROOM, onUserExitRoom);
         
         // Leave the last joined Room
         sfs.send(new LeaveRoomRequest());
     }
     
     private function onUserExitRoom(evt:SFSEvent):void
     {
         var room:Room = evt.params.room;
         var user:User = evt.params.user;
         
         trace("User " + user.name + " just left Room " + room.name);
     }