sfs2x.client.requests
Class JoinRoomRequest

java.lang.Object
  extended by sfs2x.client.requests.BaseRequest
      extended by sfs2x.client.requests.JoinRoomRequest
All Implemented Interfaces:
sfs2x.client.requests.IRequest

public class JoinRoomRequest
extends sfs2x.client.requests.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")); }

See Also:
RoomSettings.getEvents(), SFSEvent.ROOM_JOIN, SFSEvent.ROOM_JOIN_ERROR, SFSEvent.USER_ENTER_ROOM, SFSEvent.USER_COUNT_CHANGE

Field Summary
static java.lang.String KEY_AS_SPECTATOR
          *Private*
static java.lang.String KEY_PASS
          *Private*
static java.lang.String KEY_ROOM
          *Private*
static java.lang.String KEY_ROOM_ID
          *Private*
static java.lang.String KEY_ROOM_NAME
          *Private*
static java.lang.String KEY_ROOM_TO_LEAVE
          *Private*
static java.lang.String KEY_USER_LIST
          *Private*
 
Fields inherited from class sfs2x.client.requests.BaseRequest
AddBuddy, AdminMessage, AutoJoin, BanUser, BlockBuddy, CallExtension, ChangeRoomCapacity, ChangeRoomName, ChangeRoomPassword, CreateRoom, CreateSFSGame, FindRooms, FindUsers, GenericMessage, GetRoomList, GoOnline, Handshake, InitBuddyList, InvitationReply, InviteUser, JoinRoom, KEY_ERROR_CODE, KEY_ERROR_PARAMS, KickUser, LeaveRoom, Login, Logout, ManualDisconnection, ModeratorMessage, ObjectMessage, PingPong, PlayerToSpectator, PrivateMessage, PublicMessage, QuickJoinGame, RemoveBuddy, SetBuddyVariables, SetRoomVariables, SetUserVariables, SpectatorToPlayer, SubscribeRoomGroup, UnsubscribeRoomGroup
 
Constructor Summary
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
 void execute(SmartFox sfs)
          *Private*
 void validate(SmartFox sfs)
          *Private*
 
Methods inherited from class sfs2x.client.requests.BaseRequest
getId, getMessage, getTargetController, isEncrypted, setEncrypted, setId, setTargetController
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_ROOM

public static final java.lang.String KEY_ROOM
*Private*

See Also:
Constant Field Values

KEY_USER_LIST

public static final java.lang.String KEY_USER_LIST
*Private*

See Also:
Constant Field Values

KEY_ROOM_NAME

public static final java.lang.String KEY_ROOM_NAME
*Private*

See Also:
Constant Field Values

KEY_ROOM_ID

public static final java.lang.String KEY_ROOM_ID
*Private*

See Also:
Constant Field Values

KEY_PASS

public static final java.lang.String KEY_PASS
*Private*

See Also:
Constant Field Values

KEY_ROOM_TO_LEAVE

public static final java.lang.String KEY_ROOM_TO_LEAVE
*Private*

See Also:
Constant Field Values

KEY_AS_SPECTATOR

public static final java.lang.String KEY_AS_SPECTATOR
*Private*

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)
Method Detail

validate

public void validate(SmartFox sfs)
              throws sfs2x.client.exceptions.SFSValidationException
*Private*

Throws:
sfs2x.client.exceptions.SFSValidationException

execute

public void execute(SmartFox sfs)
*Private*