Package sfs2x.client.requests
Class SetUserVariablesRequest
- java.lang.Object
-
- sfs2x.client.requests.BaseRequest
-
- sfs2x.client.requests.SetUserVariablesRequest
-
- All Implemented Interfaces:
sfs2x.client.requests.IRequest
public class SetUserVariablesRequest extends BaseRequest
Sets one or more custom User Variables for the current user.When a User Variable is set, the userVariablesUpdate event is dispatched to all the users in all the Rooms joined by the current user, including himself.
NOTE: the userVariablesUpdate event is dispatched to users in a specific Room only if it is configured to allow this event (see the RoomSettings.permissions parameter).
Example
The following example sets a number of User Variables and handles the respective update event:private void someMethod() { sfs.addEventListener(SFSEvent.USER_VARIABLES_UPDATE, new IEventListener() { public void dispatch(BaseEvent evt) throws SFSException { List
changedVars = (List )evt.getArguments().get("changedVars"); User user = (User)evt.getArguments().get("user"); // Check if the user changed his x and y user variables if (changedVars.indexOf("x") != -1 || changedVars.indexOf("y") != -1) { // Move the user avatar to a new position ... } } }); // Create some User Variables List userVars = new ArrayList (); userVars.add(new SFSUserVariable("avatarType", "SwedishCook")); userVars.add(new SFSUserVariable("country", "Sweden")); userVars.add(new SFSUserVariable("x", 10)); userVars.add(new SFSUserVariable("y", 5)); sfs.send(new SetUserVariablesRequest(userVars)); }
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
KEY_USER
* API internal usage only *static java.lang.String
KEY_VAR_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 SetUserVariablesRequest(java.util.List<UserVariable> userVariables)
Creates a new SetUserVariablesRequest 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_USER
public static final java.lang.String KEY_USER
* 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
-
SetUserVariablesRequest
public SetUserVariablesRequest(java.util.List<UserVariable> userVariables)
Creates a new SetUserVariablesRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.- Parameters:
userVariables
- A list of UserVariable objects representing the User Variables to be set.- See Also:
SmartFox.send(sfs2x.client.requests.IRequest)
,UserVariable
-
-