Package sfs2x.client.requests
Class LeaveRoomRequest
- java.lang.Object
-
- sfs2x.client.requests.BaseRequest
-
- sfs2x.client.requests.LeaveRoomRequest
-
- All Implemented Interfaces:
sfs2x.client.requests.IRequest
public class LeaveRoomRequest extends 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.
Example
The following example makes the user leave the currently joined Room and handles the respective event:private void someMethod() { sfs.addEventListener(SFSEvent.USER_EXIT_ROOM, new IEventListener() { public void dispatch(BaseEvent evt) throws SFSException { Room room = (Room)evt.getArguments().get("room"); User user = (User)evt.getArguments().get("user"); System.out.println("User " + user.getName() + " just left Room " + room.getName()); } }); // Leave the last joined Room sfs.send(new LeaveRoomRequest()); }
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
KEY_ROOM_ID
* API internal usage only *-
Fields inherited from class sfs2x.client.requests.BaseRequest
AddBuddy, AdminMessage, AutoJoin, BanUser, BlockBuddy, CallExtension, ChangeRoomCapacity, ChangeRoomName, ChangeRoomPassword, ClusterInviteUsers, ClusterJoinOrCreate, CreateRoom, CreateSFSGame, FindRooms, FindUsers, GameServerConnectionRequired, GenericMessage, GetRoomList, GoOnline, Handshake, InitBuddyList, InvitationReply, InviteUser, JoinRoom, JoinRoomInvite, KEY_ERROR_CODE, KEY_ERROR_PARAMS, KickUser, LeaveRoom, Login, Logout, ManualDisconnection, ModeratorMessage, ObjectMessage, PingPong, PlayerToSpectator, PrivateMessage, PublicMessage, QuickJoinGame, QuickJoinOrCreateRoom, RemoveBuddy, SetBuddyVariables, SetRoomVariables, SetUserPosition, SetUserVariables, SpectatorToPlayer, SubscribeRoomGroup, UnsubscribeRoomGroup
-
-
Constructor Summary
Constructors Constructor Description LeaveRoomRequest()
LeaveRoomRequest(Room theRoom)
Creates a new LeaveRoomRequest instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(ISmartFox sfs)
* API internal usage only *void
validate(ISmartFox sfs)
* API internal usage only *-
Methods inherited from class sfs2x.client.requests.BaseRequest
getId, getMessage, getTargetController, isEncrypted, setEncrypted, setId, setTargetController
-
-
-
-
Field Detail
-
KEY_ROOM_ID
public static final java.lang.String KEY_ROOM_ID
* API internal usage only *- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LeaveRoomRequest
public LeaveRoomRequest(Room theRoom)
Creates a new LeaveRoomRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.- Parameters:
theRoom
- The Room object corresponding to the Room that the current user must leave. Ifnull
, the last Room joined by the user is left.- See Also:
SmartFox.send(sfs2x.client.requests.IRequest)
,Room
-
LeaveRoomRequest
public LeaveRoomRequest()
- See Also:
LeaveRoomRequest(Room)
-
-