sfs2x.client.requests
Class SpectatorToPlayerRequest

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

public class SpectatorToPlayerRequest
extends BaseRequest

Turns the current user from spectator to player in a Game Room.

If the operation is successful, all the users in the target Room are notified with the spectatorToPlayer event. The operation could fail if no player slots are available in the Game Room at the time of the request; in this case the spectatorToPlayerError event is dispatched to the requester's client.

Example
The following example turns the current user from spectator to player in the last joined Game Room:

 private void someMethod() {
     sfs.addEventListener(SFSEvent.SPECTATOR_TO_PLAYER, new IEventListener() {
         public void dispatch(BaseEvent evt) throws SFSException {
             System.out.println("Spectator " + (User)evt.getArguments().get("user") + " is now a player");
         }
     });
     sfs.addEventListener(SFSEvent.SPECTATOR_TO_PLAYER_ERROR, new IEventListener() {
         public void dispatch(BaseEvent evt) throws SFSException {
             System.out.println("Unable to become a player due to the following error: " + evt.getArguments().get("errorMessage"));
         }
     });
     
     // Switch spectator to player
     sfs.send(new SpectatorToPlayerRequest());
 }
 

See Also:
SFSEvent.SPECTATOR_TO_PLAYER, SFSEvent.SPECTATOR_TO_PLAYER_ERROR, PlayerToSpectatorRequest

Field Summary
static java.lang.String KEY_PLAYER_ID
          * API internal usage only *
static java.lang.String KEY_ROOM_ID
          * API internal usage only *
static java.lang.String KEY_USER_ID
          * API internal usage only *
 
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, JoinRoomInvite, KEY_ERROR_CODE, KEY_ERROR_PARAMS, KickUser, LeaveRoom, Login, Logout, ManualDisconnection, ModeratorMessage, ObjectMessage, PingPong, PlayerToSpectator, PrivateMessage, PublicMessage, QuickJoinGame, RemoveBuddy, SetBuddyVariables, SetRoomVariables, SetUserPosition, SetUserVariables, SpectatorToPlayer, SubscribeRoomGroup, UnsubscribeRoomGroup
 
Constructor Summary
SpectatorToPlayerRequest()
           
SpectatorToPlayerRequest(Room targetRoom)
          Creates a new SpectatorToPlayerRequest instance.
 
Method Summary
 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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_ROOM_ID

public static final java.lang.String KEY_ROOM_ID
* API internal usage only *

See Also:
Constant Field Values

KEY_USER_ID

public static final java.lang.String KEY_USER_ID
* API internal usage only *

See Also:
Constant Field Values

KEY_PLAYER_ID

public static final java.lang.String KEY_PLAYER_ID
* API internal usage only *

See Also:
Constant Field Values
Constructor Detail

SpectatorToPlayerRequest

public SpectatorToPlayerRequest(Room targetRoom)
Creates a new SpectatorToPlayerRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Parameters:
targetRoom - The Room object corresponding to the Room in which the spectator should be turned to player. If null, the last Room joined by the user is used.
See Also:
SmartFox.send(sfs2x.client.requests.IRequest), Room

SpectatorToPlayerRequest

public SpectatorToPlayerRequest()
See Also:
SpectatorToPlayerRequest(Room)
Method Detail

validate

public void validate(ISmartFox sfs)
              throws sfs2x.client.exceptions.SFSValidationException
* API internal usage only *

Throws:
sfs2x.client.exceptions.SFSValidationException

execute

public void execute(ISmartFox sfs)
* API internal usage only *