Package sfs2x.client.requests
Class SetRoomVariablesRequest
- java.lang.Object
-
- sfs2x.client.requests.BaseRequest
-
- 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
Fields Modifier and Type Field Description 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, 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 SetRoomVariablesRequest(java.util.List<RoomVariable> roomVariables)
SetRoomVariablesRequest(java.util.List<RoomVariable> roomVariables, Room room)
Creates a new SetRoomVariablesRequest 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_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; ifnull
, 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)
-
-