sfs2x.client.requests
Class SetRoomVariablesRequest

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

public class SetRoomVariablesRequest
extends BaseRequest

Sets one or more custom Room Variables in a Room.

When a Room Variable is set, the roomVariablesUpdate event is dispatched to all the users in the target Room, including the user who updated it. Also, if the Room Variable is global (see the SFSRoomVariable class description), the event is dispatched to all users who subscribed the Group to which the target Room is associated.

Example
The following example sets a number of Room Variables and handles the respective update event:

 private void someMethod() {
     sfs.addEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, new IEventListener() {
         public void dispatch(BaseEvent evt) throws SFSException {
             List changedVars = (List)evt.getArguments().get("changedVars");
             Room room = (Room)evt.getArguments().get("room");
             
             // Check if the "gameStarted" variable was changed
             if (changedVars.indexOf("gameStarted") != -1)
             {
                 if (room.getVariable("gameStarted").getBoolValue() == true)
                     System.out.println("Game started");
                 else
                     System.out.println("Game stopped");
             }
         }
     });
     
     // Create some Room Variables
     List roomVars = new ArrayList();
     roomVars.add(new SFSRoomVariable("gameStarted", false));
     roomVars.add(new SFSRoomVariable("gameType", "Snooker"));
     roomVars.add(new SFSRoomVariable("minRank", 10));
     
     sfs.send(new SetRoomVariablesRequest(roomVars));
 }
 

See Also:
SFSEvent.ROOM_VARIABLES_UPDATE, SFSRoomVariable

Field Summary
static java.lang.String KEY_VAR_LIST
          * API internal usage only *
static java.lang.String KEY_VAR_ROOM
          * 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
SetRoomVariablesRequest(java.util.List<RoomVariable> roomVariables)
           
SetRoomVariablesRequest(java.util.List<RoomVariable> roomVariables, Room room)
          Creates a new SetRoomVariablesRequest 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_VAR_ROOM

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

See Also:
Constant Field Values

KEY_VAR_LIST

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

See Also:
Constant Field Values
Constructor Detail

SetRoomVariablesRequest

public SetRoomVariablesRequest(java.util.List<RoomVariable> roomVariables,
                               Room room)
Creates a new SetRoomVariablesRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Parameters:
roomVariables - A list of RoomVariable objects representing the Room Variables to be set.
room - A Room object representing the Room where to set the Room Variables; if null, the last Room joined by the current user is used.
See Also:
SmartFox.send(sfs2x.client.requests.IRequest), RoomVariable, Room

SetRoomVariablesRequest

public SetRoomVariablesRequest(java.util.List<RoomVariable> roomVariables)
See Also:
SetRoomVariablesRequest(java.util.List, sfs2x.client.entities.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 *