Package sfs2x.client.requests
Class JoinRoomRequest
- java.lang.Object
-
- sfs2x.client.requests.BaseRequest
-
- sfs2x.client.requests.JoinRoomRequest
-
- All Implemented Interfaces:
sfs2x.client.requests.IRequest
public class JoinRoomRequest extends BaseRequest
Joins the current user in a Room.If the operation is successful, the current user receives a roomJoin event; otherwise the roomJoinError 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: userEnterRoom, dispatched to the other users inside the Room to warn them that a new user has arrived; 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 join an existing Room:private void someMethod() { sfs.addEventListener(SFSEvent.ROOM_JOIN, new IEventListener() { public void dispatch(BaseEvent evt) throws SFSException { System.out.println("Room joined successfully: " + evt.getArguments().get("room")); } }); sfs.addEventListener(SFSEvent.ROOM_JOIN_ERROR, new IEventListener() { public void dispatch(BaseEvent evt) throws SFSException { System.out.println("Room joining failed: " + evt.getArguments().get("errorMessage")); } }); // Join a Room called "Lobby" sfs.send(new JoinRoomRequest("Lobby")); }
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
KEY_AS_SPECTATOR
* API internal usage only *static java.lang.String
KEY_PASS
* API internal usage only *static java.lang.String
KEY_ROOM
* API internal usage only *static java.lang.String
KEY_ROOM_ID
* API internal usage only *static java.lang.String
KEY_ROOM_NAME
* API internal usage only *static java.lang.String
KEY_ROOM_TO_LEAVE
* API internal usage only *static java.lang.String
KEY_USER_LIST
* 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 JoinRoomRequest(java.lang.Object id)
JoinRoomRequest(java.lang.Object id, java.lang.String pass)
JoinRoomRequest(java.lang.Object id, java.lang.String pass, java.lang.Integer roomIdToLeave)
JoinRoomRequest(java.lang.Object id, java.lang.String pass, java.lang.Integer roomIdToLeave, boolean asSpectator)
Creates a new JoinRoomRequest 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
public static final java.lang.String KEY_ROOM
* API internal usage only *- See Also:
- Constant Field Values
-
KEY_USER_LIST
public static final java.lang.String KEY_USER_LIST
* API internal usage only *- See Also:
- Constant Field Values
-
KEY_ROOM_NAME
public static final java.lang.String KEY_ROOM_NAME
* API internal usage only *- See Also:
- Constant Field Values
-
KEY_ROOM_ID
public static final java.lang.String KEY_ROOM_ID
* API internal usage only *- See Also:
- Constant Field Values
-
KEY_PASS
public static final java.lang.String KEY_PASS
* API internal usage only *- See Also:
- Constant Field Values
-
KEY_ROOM_TO_LEAVE
public static final java.lang.String KEY_ROOM_TO_LEAVE
* API internal usage only *- See Also:
- Constant Field Values
-
KEY_AS_SPECTATOR
public static final java.lang.String KEY_AS_SPECTATOR
* API internal usage only *- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JoinRoomRequest
public JoinRoomRequest(java.lang.Object id, java.lang.String pass, java.lang.Integer roomIdToLeave, boolean asSpectator)
Creates a new JoinRoomRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.- Parameters:
id
- The id or the name of the Room to be joined.pass
- The password of the Room, in case it is password protected.roomIdToLeave
- The id of a previously joined Room that the user should leave when joining the new Room. By default, the last joined Room is left; if a negative number is passed, no previous Room is left.asSpectator
-true
to join the Room as a spectator (in Game Rooms only).- See Also:
SmartFox.send(sfs2x.client.requests.IRequest)
-
JoinRoomRequest
public JoinRoomRequest(java.lang.Object id, java.lang.String pass, java.lang.Integer roomIdToLeave)
-
JoinRoomRequest
public JoinRoomRequest(java.lang.Object id, java.lang.String pass)
-
JoinRoomRequest
public JoinRoomRequest(java.lang.Object id)
-
-