Class SFS2X.SFSEvent

The main event types dispatched by the SmartFoxServer 2X JavaScript API.

The constants contained in this class are used to register the event listeners; when an event is dispatched, an object containing event-specific parameters is passed to the listener. See the documentation below for a description of the parameters available for each event.

The following example shows the generic approach to be implemented to listen to events; please refer to the specific event types for the parameters object content:

var sfs = null;

function init()
{
	// Create SmartFox client instance
	sfs = new SmartFox();
	
	// Add event listener for connection
	sfs.addEventListener(SFS2X.SFSEvent.CONNECTION, onConnection, this);
	
	// Connect to the server
	sfs.connect("127.0.0.1", 9933);
}

// Handle connection event
function onConnection(evtParams)
{
	if (evtParams.success)
		console.log("Connected to SmartFoxServer 2X!");
	else
		console.log("Connection failed. Is the server running at all?");
}

Field Summary

Field Detail

<static> <constant> SFS2X.SFSEvent.ADMIN_MESSAGE
The adminMessage event type, dispatched when the current user receives a message from an administrator user.

This event is caused by the AdminMessageRequest request sent by a user with administration privileges.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
sender{SFSUser}An object representing the administrator user who sent the message.
message{String}The message sent by the administrator.
data{Object}An object containing custom parameters which might accompany the message.

The following example sends an administration message to all the users in the Zone; it also shows how to handle the related event:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ADMIN_MESSAGE, onAdminMessage, this);
	
	// Set the message recipients: all users in the Zone
	var recipMode = new SFS2X.Requests.MessageRecipientMode(SFS2X.Requests.MessageRecipientMode.TO_ZONE, null);
	
	// Send the administrator message
	sfs.send(new SFS2X.Requests.System.AdminMessageRequest("Hello to everybody from the Administrator!", recipMode));
}

function onAdminMessage(evtParams)
{
	console.log("The administrator sent the following message: " + evtParams.message);
}
See also:
SFS2X.Requests.System.AdminMessageRequest
SFS2X.Entities.SFSUser
SFS2X.SFSEvent.MODERATOR_MESSAGE
<static> <constant> SFS2X.SFSEvent.CONNECTION
The connection event type, dispatched when a connection between the client and a SmartFoxServer 2X instance is attempted.

This event is fired in response to a call to the SmartFox.connect() method.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
success{Boolean}The connection result: true if a connection was established, false otherwise.

The following example starts a connection:

function someMethod()
{
	sfs = new SmartFox();
	sfs.addEventListener(SFS2X.SFSEvent.CONNECTION, onConnection, this);
	
	sfs.connect(127.0.0.1, 9933);
}

function onConnection(evtParams)
{
	if (evtParams.success)
		console.log("Connection established");
	else
		console.log("Connection failed");
}
See also:
SFS2X.SmartFox#connect
SFS2X.SFSEvent.CONNECTION_LOST
<static> <constant> SFS2X.SFSEvent.CONNECTION_LOST
The connectionLost event type, dispatched when the connection between the client and the SmartFoxServer 2X instance is interrupted.

This event is fired in response to a call to the SmartFox.disconnect() method.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
reason{String}The reason of the disconnection, among those available in the ClientDisconnectionReason class.

The following example handles a disconnection event:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.CONNECTION_LOST, onConnectionLost, this);
}

function onConnectionLost(evtParams)
{
	var reason = evtParams.reason;
	
	if (reason != SFS2X.Utils.ClientDisconnectionReason.MANUAL)
	{
		if (reason == SFS2X.Utils.ClientDisconnectionReason.IDLE)
			console.log("A disconnection occurred due to inactivity");
		else if (reason == SFS2X.Utils.ClientDisconnectionReason.KICK)
			console.log("You have been kicked by the moderator");
		else if (reason == SFS2X.Utils.ClientDisconnectionReason.BAN)
			console.log("You have been banned by the moderator");
		else
			console.log("A disconnection occurred due to unknown reason; please check the server log");
	}
	else
	{
		// Manual disconnection is usually ignored
	}
}
See also:
SFS2X.SmartFox#disconnect
SFS2X.Utils.ClientDisconnectionReason
SFS2X.SFSEvent.CONNECTION
SFS2X.SFSEvent.CONNECTION_RETRY
<static> <constant> SFS2X.SFSEvent.EXTENSION_RESPONSE
The extensionResponse event type, dispatched when data coming from a server-side Extension is received by the current user.

Data is usually sent by the server to one or more clients in response to an ExtensionRequest request, but not necessarily.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
cmd{String}The name of the command which identifies an action that should be executed by the client. If this event is fired in response to a request sent by the client, it is a common practice to use the same command name passed to the request also in the response.
params{Object}An object containing custom data sent by the Extension.
sourceRoom{Number}[DEPRECATED - Use room property]The id of the Room which the Extension is attached to (for Room Extensions only).
room{SFSRoom}An object representing the Room which the Extension is attached to (for Room Extensions only).

The following example sends a command to the Zone Extension; it also handles responses coming from the Extension by implementing the extensionResponse listener (the same command name is used in both the request and the response):

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.EXTENSION_RESPONSE, onExtensionResponse, this);
	
	// Send two integers to the Zone extension and get their sum in return
	var params = {};
	params.n1 = 26;
	params.n2 = 16;
	
	sfs.send(new SFS2X.Requests.System.ExtensionRequest("add", params));
}

function onExtensionResponse(evtParams)
{
	if (evtParams.cmd == "add")
	{
		var responseParams = evtParams.params;
		
		// We expect a number called "sum"
		console.log("The sum is: " + responseParams.sum);
	}
}
See also:
SFS2X.Requests.System.ExtensionRequest
<static> <constant> SFS2X.SFSEvent.INVITATION
The invitation event type, dispatched when the current user receives an invitation from another user.

This event is caused by the InviteUsersRequest and CreateSFSGameRequest requests; the user is supposed to reply using the InvitationReplyRequest request.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
invitation{Invitation}An object representing the invitation received by the current user.

The following example receives an invitation and accepts it automatically; in a real case scenario, the application interface usually allows the user choosing to accept or refuse the invitation, or even ignore it:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.INVITATION, onInvitationReceived, this);
	sfs.addEventListener(SFS2X.SFSEvent.INVITATION_REPLY_ERROR, onInvitationReplyError, this);
}

function onInvitationReceived(evtParams)
{
	// Let's accept this invitation			
	sfs.send(new SFS2X.Requests.Game.InvitationReplyRequest(evtParams.invitation, SFS2X.Entities.Invitation.InvitationReply.ACCEPT));
}

function onInvitationReplyError(evtParams)
{
	console.log("Failed to reply to invitation due to the following problem: " + evtParams.errorMessage);
}
See also:
SFS2X.Requests.Game.InviteUsersRequest
SFS2X.Requests.Game.InvitationReplyRequest
SFS2X.Entities.Invitation.Invitation
SFS2X.SFSEvent.INVITATION_REPLY
<static> <constant> SFS2X.SFSEvent.INVITATION_REPLY
The invitationReply event type, dispatched when the current user receives a reply to an invitation he sent previously.

This event is caused by the InvitationReplyRequest request sent by the invitee.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
invitee{SFSUser}An object representing the user who replied to the invitation.
reply{Number}The answer to the invitation among those available as constants in the InvitationReply class.
data{Object}An object containing custom parameters, for example a message describing the reason of refusal.

See the example provided in the INVITATION constant description.

See also:
SFS2X.Requests.Game.InvitationReplyRequest
SFS2X.Entities.Invitation.InvitationReply
SFS2X.SFSEvent.INVITATION
SFS2X.SFSEvent.INVITATION_REPLY_ERROR
<static> <constant> SFS2X.SFSEvent.INVITATION_REPLY_ERROR
The invitationReplyError event type, dispatched when an error occurs while the current user is sending a reply to an invitation he received.

This event is fired in response to the InvitationReplyRequest request in case the operation failed.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}A message containing the description of the error.
errorCode{Number}The error code.

See the example provided in the INVITATION constant description.

See also:
SFS2X.Requests.System.Game.InvitationReplyRequest
SFS2X.SFSEvent.INVITATION_REPLY
SFS2X.SFSEvent.INVITATION
<static> <constant> SFS2X.SFSEvent.LOGIN
The login event type, dispatched when the current user performs a successful login in a server Zone.

This event is fired in response to the LoginRequest request.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
user{SFSUser}An object representing the user who performed the login.
data{Object}An object containing custom parameters returned by a custom login system, if any.

The following example performs a login in the "SimpleChat" Zone:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.LOGIN, onLogin, this);
	sfs.addEventListener(SFS2X.SFSEvent.LOGIN_ERROR, onLoginError, this);
	
	// Login
	sfs.send(new SFS2X.Requests.System.LoginRequest("FozzieTheBear", "", "SimpleChat"));
}

function onLogin(evtParams)
{
	console.log("Login successful!");
}

function onLoginError(evtParams
{
	console.log("Login failure: " + evtParams.errorMessage);
}
See also:
SFS2X.Requests.System.LoginRequest
SFS2X.Entities.SFSUser
<static> <constant> SFS2X.SFSEvent.LOGIN_ERROR
The loginError event type, dispatched if an error occurs while the user login is being performed.

This event is fired in response to the LoginRequest request in case the operation failed.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}A message containing the description of the error.
errorCode{Number}The error code.

See the example provided in the LOGIN constant description.

See also:
SFS2X.Requests.System.LoginRequest
SFS2X.SFSEvent.LOGIN
<static> <constant> SFS2X.SFSEvent.LOGOUT
The logout event type, dispatched when the current user performs logs out of the server Zone.

This event is fired in response to the LogoutRequest request.

No parameters are available for this event object.

The following example performs a logout from the current Zone:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.LOGOUT, onLogout, this);
	
	// Logout
	sfs.send(new SFS2X.Requests.System.LogoutRequest());
}

function onLogout(evtParams)
{
	console.log("Logout executed!");
}
See also:
SFS2X.Requests.System.LogoutRequest
SFS2X.SFSEvent.LOGIN
<static> <constant> SFS2X.SFSEvent.MMOITEM_VARIABLES_UPDATE
The mmoItemVariablesUpdate event type, dispatched when an MMOItem Variable is updated in an MMORoom.

This event is caused by an MMOItem Variable being set, updated or deleted in a server side Extension, and it is received only if the current user has the related MMOItem in his Area of Interest.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{MMORoom}The MMORoom where the MMOItem whose Variables have been updated is located.
mmoItem{MMOItem}The MMOItem whose variables have been updated.
changedVars{Array}The list of names of the MMOItem Variables that were changed (or created for the first time).

The following example shows how to handle the MMOItem Variable update:

function onMMOItemVarsUpdate(evtParams)
{
	var changedVars = evtParams.changedVars;
	var item = evtParams.mmoItem;
	
	// Check if the MMOItem was moved 
	if (changedVars.indexOf("x") != -1 || changedVars.indexOf("y") != -1)
	{
		// Move the sprite representing the MMOItem on screen
		...
	}
}
See also:
SFS2X.Entities.MMOItem
SFS2X.Entities.MMORoom
<static> <constant> SFS2X.SFSEvent.MODERATOR_MESSAGE
The moderatorMessage event type, dispatched when the current user receives a message from a moderator user.

This event can be caused by either the ModeratorMessageRequest, KickUserRequest or BanUserRequest requests sent by a user with at least moderation privileges. Also, this event can be caused by a kick/ban action performed through the SmartFoxServer 2X Administration Tool.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
sender{SFSUser}An object representing the moderator user who sent the message.
message{String}The message sent by the moderator.
data{Object}An object containing custom parameters which might accompany the message.

The following example sends a moderator message to all the users in the last joned Room; it also shows how to handle the related event:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.MODERATOR_MESSAGE, onModeratorMessage, this);
	
	// Set the message recipients: all users in the current Room
	var recipMode = new SFS2X.Requests.MessageRecipientMode(SFS2X.Requests.MessageRecipientMode.TO_ROOM, sfs.lastJoinedRoom);
	
	// Send the moderator message
	sfs.send(new SFS2X.Requests.System.ModeratorMessageRequest("Hello everybody, I'm the Moderator!", recipMode));
}

function onModeratorMessage(evtParams)
{
	console.log("The moderator sent the following message: " + evtParams.message);
}
See also:
SFS2X.Requests.System.ModeratorMessageRequest
SFS2X.Requests.System.KickUserRequest
SFS2X.Requests.System.BanUserRequest
SFS2X.Entities.SFSUser
SFS2X.SFSEvent.ADMIN_MESSAGE
<static> <constant> SFS2X.SFSEvent.OBJECT_MESSAGE
The objectMessage event type, dispatched when an object containing custom data is received by the current user.

This event is caused by an ObjectMessageRequest request sent by any user in the target Room.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
sender{SFSUser}An object representing the user who sent the message.
message{Object}The content of the message: an object containing the custom parameters sent by the sender.

The following example sends the player's avatar movement coordinates and handles the respective event (note: the myAvatar instance is supposed to be the user sprite on the stage, while the getUserAvatar method retrieves the sprite of other users' characters):

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.OBJECT_MESSAGE, onObjectMessage, this);
	
	// Send my movement to all players
	var dataObj = {};
	dataObj.x = myAvatar.x;
	dataObj.y = myAvatar.y;
	
	sfs.send(new SFS2X.Requests.System.ObjectMessageRequest(dataObj));
}

private function onObjectMessage(evtParams)
{
	var dataObj = evtParams.message;
	
	var sender = evtParams.sender;
	var avatar = getUserAvatar(sender.id);
	
	avatar.x = dataObj.x;
	avatar.y = dataObj.y;
}
See also:
SFS2X.Requests.System.ObjectMessageRequest
SFS2X.Entities.SFSUser
<static> <constant> SFS2X.SFSEvent.PING_PONG
The pingPong event type, dispatched when a new lag value measurement is available.

This event is fired when the automatic lag monitoring is turned on by passing true to the enableLagMonitor() method.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
lagValue{Number}The average of the last ten measured lag values, expressed in milliseconds.
See also:
SFS2X.SmartFox#enableLagMonitor
<static> <constant> SFS2X.SFSEvent.PLAYER_TO_SPECTATOR
The playerToSpectator event type, dispatched when a player is turned to a spectator inside a Game Room.

This event is fired in response to the PlayerToSpectatorRequest> request if the operation is executed successfully.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{SFSRoom}An object representing the Room in which the player is turned to spectator.
user{SFSUser}An object representing the player who was turned to spectator.

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

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.PLAYER_TO_SPECTATOR, onPlayerToSpectatorSwitch, this);
	sfs.addEventListener(SFS2X.SFSEvent.PLAYER_TO_SPECTATOR_ERROR, onPlayerToSpectatorSwitchError, this);
	
	// Switch player to spectator
	sfs.send(new SFS2X.Requests.System.PlayerToSpectatorRequest());
}

function onPlayerToSpectatorSwitch(evtParams)
{
	console.log("Player " + evtParams.user + " is now a spectator");
}

function onPlayerToSpectatorSwitchError(evtParams)
{
	console.log("Unable to become a spectator due to the following error: " + evtParams.errorMessage);
}
See also:
SFS2X.Requests.System.PlayerToSpectatorRequest
SFS2X.Entities.SFSUser
SFS2X.Entities.SFSRoom
SFS2X.SFSEvent.PLAYER_TO_SPECTATOR_ERROR
SFS2X.SFSEvent.SPECTATOR_TO_PLAYER
<static> <constant> SFS2X.SFSEvent.PLAYER_TO_SPECTATOR_ERROR
The playerToSpectatorError event type, dispatched when an error occurs while the current user is being turned from player to spectator in a Game Room.

This event is fired in response to the PlayerToSpectatorRequest request in case the operation failed.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}A message containing the description of the error.
errorCode{Number}The error code.

See the example provided in the PLAYER_TO_SPECTATOR constant description.

See also:
SFS2X.Requests.System.PlayerToSpectatorRequest
SFS2X.SFSEvent.PLAYER_TO_SPECTATOR
<static> <constant> SFS2X.SFSEvent.PRIVATE_MESSAGE
The privateMessage event type, dispatched when a private message is received by the current user.

This event is caused by a PrivateMessageRequest request sent by any user in the Zone.

NOTE: the same event is fired by the sender's client too, so that the user is aware that the message was delivered successfully to the recipient, and it can be displayed in the private chat area keeping the correct message ordering. In this case there is no default way to know who the message was originally sent to. As this information can be useful in scenarios where the sender is chatting privately with more than one user at the same time in separate windows or tabs (and we need to write his own message in the proper one), the data parameter can be used to store, for example, the id of the recipient user.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
sender{SFSUser}An object representing the user who sent the message.
message{String}The message sent by the user.
data{Object}An object containing custom parameters which might accompany the message.

The following example sends a private message and handles the respective event:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.PRIVATE_MESSAGE, onPrivateMessage, this);
	
	// Send a private message to Jack
	var user = sfs.usermanager.getUserByName("Jack");
	sfs.send(new SFS2X.Requests.System.PrivateMessageRequest("Hello my friend!", user.id));
}

function onPrivateMessage(evtparams
{
	// As messages are forwarded to the sender too,
	// I have to check if I am the sender
	
	var sender = evtParams.sender;
	
	if (sender != sfs.mySelf)
		console.log("User " + sender.name + " sent me this PM: " + evtParams.message);
}
See also:
SFS2X.Requests.System.PrivateMessageRequest
SFS2X.Entities.SFSUser
SFS2X.SFSEvent.PUBLIC_MESSAGE
<static> <constant> SFS2X.SFSEvent.PROXIMITY_LIST_UPDATE
The proximityListUpdate event type, dispatched when one more users or one or more MMOItem objects enter/leave the current user's Area of Interest in MMORooms.

This event is fired after an MMORoom is joined and the SetUserPositionRequest request is sent at least one time.

NOTE: this event substitutes the default userEnterRoom and userExitRoom events available in regular Rooms.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
addedUsers{Array}A list of User objects representing the users who entered the current user's Area of Interest.
removedUsers{Array}A list of User objects representing the users who left the current user's Area of Interest.
addedItems{Array}A list of MMOItem objects which entered the current user's Area of Interest.
removedItems{Array}A list of MMOItem objects which left the current user's Area of Interest.

The following example shows how to handle the proximity user list provided by the event in order to add new avatars on the screen and remove those who left the current user's proximity range:

function onProximityListUpdate(evtParams)
{
	var added = evtParams.addedUsers;
	var removed = evtParams.removedUsers;
	
	// Add users that entered the proximity list
	for (var i = 0; i < added.length; i++)
	{
		var user = added[i];
		
		// Obtain the coordinates at which the user "appeared" in our range
		var entryPoint = user.aoiEntryPoint;
	
		// Add new avatar on screen
		var avatarSprite = new AvatarSprite();
		avatarSprite.x = entryPoint.px;
		avatarSprite.y = entryPoint.py;
		...
	}
	
	// Remove users that left the proximity list
	for (var j = 0; j < removed.length; j++)
	{
		var user = removed[j];
		
		// Remove the avatar from screen
		...
	}
}
See also:
SFS2X.Requests.MMO.SetUserPositionRequest
SFS2X.Entities.MMORoom
SFS2X.Entities.MMOItem
<static> <constant> SFS2X.SFSEvent.PUBLIC_MESSAGE
The publicMessage event type, dispatched when a public message is received by the current user.

This event is caused by a PublicMessageRequest request sent by any user in the target Room, including the current user himself.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{SFSRoom}An object representing the Room at which the message is targeted.
sender{SFSUser}An object representing the user who sent the message.
message{String}The message sent by the user.
data{Object}An object containing custom parameters which might accompany the message.

The following example sends a public message and handles the respective event:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.PUBLIC_MESSAGE, onPublicMessage, this);
	
	// Send a public message
	sfs.send(new SFS2X.Requests.System.PublicMessageRequest("Hello everyone!"));
}

function onPublicMessage(evtParams)
{
	// As messages are forwarded to the sender too,
	// I have to check if I am the sender
	
	var sender = evtParams.sender;
	
	if (sender == sfs.mySelf)
		console.log("I said: " + evtParams.message);
	else
		console.log("User " + sender.name + " said: " + evtParams.message);
}
See also:
SFS2X.Requests.System.PublicMessageRequest
SFS2X.Entities.SFSRoom
SFS2X.Entities.SFSUser
SFS2X.SFSEvent.PRIVATE_MESSAGE
<static> <constant> SFS2X.SFSEvent.ROOM_ADD
The roomAdd event type, dispatched when a new Room is created inside the Zone under any of the Room Groups that the client subscribed.

This event is fired in response to the CreateRoomRequest and CreateSFSGameRequest requests in case the operation is executed successfully.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{SFSRoom}An object representing the Room that was created.

The following example creates a new chat Room:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_ADD, onRoomCreated, this);
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_CREATION_ERROR, onRoomCreationError, this);
	
	// Define the settings of a new chat Room
	var settings = new SFS2X.Requests.RoomSettings("My Chat Room");
	settings.maxUsers = 40;
	settings.groupId = "chats";
	
	// Create the Room
	sfs.send(new SFS2X.Requests.System.CreateRoomRequest(settings));
}

function onRoomCreated(evtParams)
{
	console.log("Room created: " + evtParams.room);
}

function onRoomCreationError(evtParams)
{
	console.log("Room creation failure: " + evtParams.errorMessage);
}
See also:
SFS2X.Requests.System.CreateRoomRequest
SFS2X.Requests.Game.CreateSFSGameRequest
SFS2X.Entities.SFSRoom
SFS2X.SFSEvent.ROOM_REMOVE
SFS2X.SFSEvent.ROOM_CREATION_ERROR
<static> <constant> SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE
The roomCapacityChange event type, dispatched when the capacity of a Room is changed.

This event is fired in response to the ChangeRoomCapacityRequest> request if the operation is executed successfully.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{SFSRoom}An object representing the Room whose capacity was changed.

The following example changes the capacity of an existing Room:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE, onRoomCapacityChanged, this);
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE_ERROR, onRoomCapacityChangeError, this);
	
	var theRoom = sfs.getRoomByName("Gonzo's Room");
	
	// Resize the Room so that it allows a maximum of 100 users and zero spectators
	sfs.send(new SFS2X.Requests.System.ChangeRoomCapacityRequest(theRoom, 100, 0));
}

function onRoomCapacityChanged(evtParams)
{
	console.log("The capacity of Room " + evtParams.room.name + " was changed successfully");
}

function onRoomCapacityChangeError(evtParams)
{
	console.log("Room capacity change failed: " + evtParams.errorMessage);
}
See also:
SFS2X.Requests.System.ChangeRoomCapacityRequest
SFS2X.Entities.SFSRoom
SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE_ERROR
<static> <constant> SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE_ERROR
The roomCapacityChangeError event type, dispatched when an error occurs while attempting to change the capacity of a Room.

This event is fired in response to the ChangeRoomCapacityRequest request in case the operation failed.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}A message containing the description of the error.
errorCode{Number}The error code.

See the example provided in the ROOM_CAPACITY_CHANGE constant description.

See also:
SFS2X.Requests.System.ChangeRoomCapacityRequest
SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE
<static> <constant> SFS2X.SFSEvent.ROOM_CREATION_ERROR
The roomCreationError event type, dispatched if an error occurs while creating a new Room.

This event is fired in response to the CreateRoomRequest and CreateSFSGameRequest requests in case the operation failed.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}A message containing the description of the error.
errorCode{Number}The error code.

See the example provided in the ROOM_ADD constant description.

See also:
SFS2X.Requests.System.CreateRoomRequest
SFS2X.Requests.Game.CreateSFSGameRequest
SFS2X.SFSEvent.ROOM_ADD
<static> <constant> SFS2X.SFSEvent.ROOM_FIND_RESULT
The roomFindResult event type, dispatched when a Rooms search is completed.

This event is fired in response to the FindRoomsRequest request to return the search result.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
rooms{Array}A list of SFSRoom objects representing the Rooms matching the search criteria. If no Room is found, the list is empty.

The following example looks for all the server Rooms whose "country" Room Variable is set to "Sweden":

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_FIND_RESULT, onRoomFindResult, this);
	
	// Create a matching expression to find Rooms with a "country" variable equal to "Sweden"
	var exp = new SFS2X.Entities.Match.MatchExpression("country", SFS2X.Entities.Match.StringMatch.EQUALS, "Sweden");
	
	// Find the Rooms
	sfs.send(new SFS2X.Requests.System.FindRoomRequest(exp));
}

function onRoomFindResult(evtParams)
{
	console.log("Rooms found: " + evtParams.rooms);
}
See also:
SFS2X.Requests.System.FindRoomsRequest
SFS2X.Entities.SFSRoom
<static> <constant> SFS2X.SFSEvent.ROOM_GROUP_SUBSCRIBE
The roomGroupSubscribe event type, dispatched when a Group is subscribed by the current user.

This event is fired in response to the SubscribeRoomGroupRequest> request if the operation is executed successfully.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
groupId{String}The name of the Group that was subscribed.
newRooms{Array}A list of SFSRoom objects representing the Rooms belonging to the subscribed Group.

The following example makes the current user subscribe a Group:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_GROUP_SUBSCRIBE, onGroupSubscribed, this);
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR, onGroupSubscribeError, this);
	
	// Subscribe the "cardGames" group
	sfs.send(new SFS2X.Requests.System.SubscribeRoomGroupRequest("cardGames"));
}

function onGroupSubscribed(evtParams)
{
	console.log("Group subscribed. The following rooms are now accessible: " + evtParams.newRooms);
}

function onGroupSubscribeError(evtParams)
{
	console.log("Group subscription failed: " + evtParams.errorMessage);
}
See also:
SFS2X.Requests.System.SubscribeRoomGroupRequest
SFS2X.Entities.SFSRoom
SFS2X.SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR
SFS2X.SFSEvent.ROOM_GROUP_UNSUBSCRIBE
<static> <constant> SFS2X.SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR
The roomGroupSubscribeError event type, dispatched when an error occurs while a Room Group is being subscribed.

This event is fired in response to the SubscribeRoomGroupRequest request in case the operation failed.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}A message containing the description of the error.
errorCode{Number}The error code.

See the example provided in the ROOM_GROUP_SUBSCRIBE constant description.

See also:
SFS2X.Requests.System.SubscribeRoomGroupRequest
SFS2X.SFSEvent.ROOM_GROUP_SUBSCRIBE
<static> <constant> SFS2X.SFSEvent.ROOM_GROUP_UNSUBSCRIBE
The roomGroupUnsubscribe event type, dispatched when a Group is unsubscribed by the current user.

This event is fired in response to the UnsubscribeRoomGroupRequest> request if the operation is executed successfully.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
groupId{String}The name of the Group that was unsubscribed.

The following example makes the current user unsubscribe a Group:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_GROUP_UNSUBSCRIBE, onGroupUnsubscribed, this);
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_GROUP_UNSUBSCRIBE_ERROR, onGroupUnsubscribeError, this);
	
	// Unsubscribe the "cardGames" group
	sfs.send(new SFS2X.Requests.System.UnsubscribeRoomGroupRequest("cardGames"));
}

function onGroupUnsubscribed(evtParams)
{
	console.log("Group unsubscribed: " + evtParams.groupId);
}

function onGroupUnsubscribeError(evtParams)
{
	console.log("Group unsubscribing failed: " + evtParams.errorMessage);
}
See also:
SFS2X.Requests.System.UnsubscribeRoomGroupRequest
SFS2X.SFSEvent.ROOM_GROUP_UNSUBSCRIBE_ERROR
SFS2X.SFSEvent.ROOM_GROUP_SUBSCRIBE
<static> <constant> SFS2X.SFSEvent.ROOM_GROUP_UNSUBSCRIBE_ERROR
The roomGroupUnsubscribeError event type, dispatched when an error occurs while a Room Group is being unsubscribed.

This event is fired in response to the UnsubscribeRoomGroupRequest request in case the operation failed.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}A message containing the description of the error.
errorCode{Number}The error code.

See the example provided in the ROOM_GROUP_UNSUBSCRIBE constant description.

See also:
SFS2X.Requests.System.UnsubscribeRoomGroupRequest
SFS2X.SFSEvent.ROOM_GROUP_UNSUBSCRIBE
<static> <constant> SFS2X.SFSEvent.ROOM_JOIN
The roomJoin event type, dispatched when a Room is joined by the current user.

This event is fired in response to the JoinRoomRequest and QuickJoinGameRequest requests in case the operation is executed successfully.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{SFSRoom}An object representing the Room that was joined.

The following example makes the user join an existing Room:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_JOIN, onRoomJoined, this);
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_JOIN_ERROR, onRoomJoinError, this);
	
	// Join a Room called "Lobby"
	sfs.send(new SFS2X.Requests.System.JoinRoomRequest("Lobby"));
}

function onRoomJoined(evtParams)
{
	console.log("Room joined successfully: " + evtParams.room);
}

function onRoomJoinError(evtParams)
{
	console.log("Room joining failed: " + evtParams.errorMessage);
}
See also:
SFS2X.Requests.System.JoinRoomRequest
SFS2X.Requests.Game.QuickJoinGameRequest
SFS2X.Entities.SFSRoom
SFS2X.SFSEvent.ROOM_JOIN_ERROR
<static> <constant> SFS2X.SFSEvent.ROOM_JOIN_ERROR
The roomJoinError event type, dispatched when an error occurs while the current user is trying to join a Room.

This event is fired in response to the JoinRoomRequest request in case the operation failed.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}A message containing the description of the error.
errorCode{Number}The error code.

See the example provided in the ROOM_JOIN constant description.

See also:
SFS2X.Requests.System.JoinRoomRequest
SFS2X.SFSEvent.ROOM_JOIN
<static> <constant> SFS2X.SFSEvent.ROOM_NAME_CHANGE
The roomNameChange event type, dispatched when the name of a Room is changed.

This event is fired in response to the ChangeRoomNameRequest request if the operation is executed successfully.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{SFSRoom}An object representing the Room which was renamed.
oldName{String}The previous name of the Room.

The following example renames an existing Room:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_NAME_CHANGE, onRoomNameChanged, this);
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_NAME_CHANGE_ERROR, onRoomNameChangeError, this);
	
	var theRoom = sfs.getRoomByName("Gonzo's Room");
	sfs.send(new SFS2X.Requests.System.ChangeRoomNameRequest(theRoom, "Gonzo The Great's Room"));
}

function onRoomNameChanged(evtParams)
{
	console.log("Room " + evtParams.oldName + " was successfully renamed to " + evtParams.room.name);
}

function onRoomNameChangeError(evtParams)
{
	console.log("Room name change failed: " + evtParams.errorMessage);
}
See also:
SFS2X.Requests.System.ChangeRoomNameRequest
SFS2X.Entities.SFSRoom
SFS2X.SFSEvent.ROOM_NAME_CHANGE_ERROR
<static> <constant> SFS2X.SFSEvent.ROOM_NAME_CHANGE_ERROR
The roomNameChangeError event type, dispatched when an error occurs while attempting to change the name of a Room.

This event is fired in response to the ChangeRoomNameRequest request in case the operation failed.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}A message containing the description of the error.
errorCode{Number}The error code.

See the example provided in the ROOM_NAME_CHANGE constant description.

See also:
SFS2X.Requests.System.ChangeRoomNameRequest
SFS2X.SFSEvent.ROOM_NAME_CHANGE
<static> <constant> SFS2X.SFSEvent.ROOM_PASSWORD_STATE_CHANGE
The roomPasswordStateChange event type, dispatched when the password of a Room is set, changed or removed.

This event is fired in response to the ChangeRoomPasswordStateRequest> request if the operation is executed successfully.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{SFSRoom}An object representing the Room whose password was changed.

The following example changes the password of an existing Room:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_PASSWORD_STATE_CHANGE, onRoomPasswordStateChanged, this);
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR, onRoomPasswordStateChangeError, this);
	
	var theRoom = sfs.getRoomByName("Gonzo's Room");
	sfs.send(new SFS2X.Requests.System.ChangeRoomPasswordStateRequest(theRoom, "mammamia"));
}

function onRoomPasswordStateChanged(evtParams)
{
	console.log("The password of Room " + evtParams.room.name + " was changed successfully");
}

function onRoomPasswordStateChangeError(evtParams)
{
	console.log("Room password change failed: " + evtParams.errorMessage);
}
See also:
SFS2X.Requests.System.ChangeRoomPasswordStateRequest
SFS2X.Entities.SFSRoom
SFS2X.SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR
<static> <constant> SFS2X.SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR
The roomPasswordStateChangeError event type, dispatched when an error occurs while attempting to set, change or remove the password of a Room.

This event is fired in response to the ChangeRoomPasswordStateRequest request in case the operation failed.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}A message containing the description of the error.
errorCode{Number}The error code.

See the example provided in the ROOM_PASSWORD_STATE_CHANGE constant description.

See also:
SFS2X.Requests.System.ChangeRoomPasswordStateRequest
SFS2X.SFSEvent.ROOM_PASSWORD_STATE_CHANGE
<static> <constant> SFS2X.SFSEvent.ROOM_REMOVE
The roomRemove event type, dispatched when a Room belonging to one of the Groups subscribed by the client is removed from the Zone.
The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{SFSRoom}An object representing the Room that was removed.

The following example shows how to handle this event type:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_REMOVE, onRoomRemoved, this);
}

function onRoomRemoved(evtParams)
{
	console.log("The following Room was removed: " + evtParams.room);
}
See also:
SFS2X.Entities.SFSRoom
SFS2X.SFSEvent.ROOM_ADD
<static> <constant> SFS2X.SFSEvent.ROOM_VARIABLES_UPDATE
The roomVariablesUpdate event type, dispatched when a Room Variable is updated.

This event is caused by the SetRoomVariablesRequest request. The request could have been sent by a user in the same Room of the current user or, in case of a global Room Variable, by a user in a Room belonging to one of the Groups subscribed by the current client.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{SFSRoom}An object representing the Room where the Room Variable update occurred.
changedVars{Array}The list of names of the Room Variables that were changed (or created for the first time).

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

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_VARIABLES_UPDATE, onRoomVarsUpdate, this);
	
	// Create some Room Variables
	var roomVars = [];
	roomVars.push(new SFS2X.Entities.Variables.SFSRoomVariable("gameStarted", false));
	roomVars.push(new SFS2X.Entities.Variables.SFSRoomVariable("gameType", "Snooker"));
	roomVars.push(new SFS2X.Entities.Variables.SFSRoomVariable("minRank", 10));
	
	sfs.send(new SFS2X.Requests.System.SetRoomVariablesRequest(roomVars));
}

function onRoomVarsUpdate(evtParams)
{
	var changedVars = evtParams.changedVars;
	var room = evtParams.room;
	
	// Check if the "gameStarted" variable was changed
	if (changedVars.indexOf("gameStarted") != -1)
	{
		if (room.getVariable("gameStarted") == true)
			console.log("Game started");
		else
			console.log("Game stopped");
	}
}
See also:
SFS2X.Requests.System.SetRoomVariablesRequest
SFS2X.Entities.SFSRoom
<static> <constant> SFS2X.SFSEvent.SOCKET_ERROR
The socketError event type, dispatched when a low level socket error is detected, for example bad/inconsistent data.
The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}The description of the error.
<static> <constant> SFS2X.SFSEvent.SPECTATOR_TO_PLAYER
The spectatorToPlayer event type, dispatched when a spectator is turned to a player inside a Game Room.

This event is fired in response to the SpectatorToPlayerRequest> request if the operation is executed successfully.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{SFSRoom}An object representing the Room in which the spectator is turned to player.
user{SFSUser}An object representing the spectator who was turned to player.
playerId{Number}The player id of the user.

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

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.SPECTATOR_TO_PLAYER, onSpectatorToPlayerSwitch, this);
	sfs.addEventListener(SFS2X.SFSEvent.SPECTATOR_TO_PLAYER_ERROR, onSpectatorToPlayerSwitchError, this);
	
	// Switch spectator to player
	sfs.send(new SFS2X.Requests.System.SpectatorToPlayerRequest());
}

function onSpectatorToPlayerSwitch(evtParams)
{
	console.log("Spectator " + evtParams.user + " is now a player");
}

function onSpectatorToPlayerSwitchError(evtParams)
{
	console.log("Unable to become a player due to the following error: " + evtParams.errorMessage);
}
See also:
SFS2X.Requests.System.SpectatorToPlayerRequest
SFS2X.Entities.SFSUser
SFS2X.Entities.SFSRoom
SFS2X.SFSEvent.SPECTATOR_TO_PLAYER_ERROR
SFS2X.SFSEvent.PLAYER_TO_SPECTATOR
<static> <constant> SFS2X.SFSEvent.SPECTATOR_TO_PLAYER_ERROR
The spectatorToPlayerError event type, dispatched when an error occurs while the current user is being turned from spectator to player in a Game Room.

This event is fired in response to the SpectatorToPlayerRequest request in case the operation failed.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
errorMessage{String}A message containing the description of the error.
errorCode{Number}The error code.

See the example provided in the SPECTATOR_TO_PLAYER constant description.

See also:
SFS2X.Requests.System.SpectatorToPlayerRequest
SFS2X.SFSEvent.SPECTATOR_TO_PLAYER
<static> <constant> SFS2X.SFSEvent.USER_COUNT_CHANGE
The userCountChange event type, dispatched when the number of users/players or spectators inside a Room changes.

This event is caused by a JoinRoomRequest request or a LeaveRoomRequest request. The Room must belong to one of the Groups subscribed by the current client; also this event might be fired or not depending on the Room configuration defined upon its creation (see the RoomSettings.events setting).

The object passed to the listener contains the following parameters:
PropertyTypeDescription
room{SFSRoom}An object representing the Room in which the users count changed.
uCount{Number}The new users count (players in case of Game Room).
sCount{Number}The new spectators count (Game Room only).

The following example shows how to handle this event type:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.USER_COUNT_CHANGE, onUserCountChange, this);
}

function onUserCountChange(evtParams)
{
	var room = evtParams.room;
	var uCount = evtParams.uCount;
	var sCount = evtParams.sCount;
	
	console.log("Room: " + room.name + " now contains " + uCount + " users and " + sCount + " spectators");
}
See also:
SFS2X.Requests.System.JoinRoomRequest
SFS2X.Requests.System.LeaveRoomRequest
SFS2X.Requests.RoomSettings#events
SFS2X.Entities.SFSRoom
SFS2X.SFSEvent.USER_ENTER_ROOM
SFS2X.SFSEvent.USER_EXIT_ROOM
<static> <constant> SFS2X.SFSEvent.USER_ENTER_ROOM
The userEnterRoom event type, dispatched when one of the Rooms joined by the current user is entered by another user.

This event is caused by a JoinRoomRequest request; it might be fired or not depending on the Room configuration defined upon its creation (see the RoomSettings.events setting).

NOTE: if the Room is of type MMORoom, this event is never fired and it is substituted by the proximityListUpdate event.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
user{SFSUser}An object representing the user who joined the Room.
room{SFSRoom}An object representing the Room that was joined by a user.

The following example shows how to handle this event type:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.USER_ENTER_ROOM, onUserEnterRoom, this);
}

function onUserEnterRoom(evtParams)
{
	var room = evtParams.room;
	var user = evtParams.user;
	
	console.log("User " + user.name + " just joined Room " + room.name);
}
See also:
SFS2X.Requests.System.JoinRoomRequest
SFS2X.Requests.RoomSettings#events
SFS2X.Entities.SFSUser
SFS2X.Entities.SFSRoom
SFS2X.Entities.MMORoom
SFS2X.SFSEvent.USER_EXIT_ROOM
SFS2X.SFSEvent.USER_COUNT_CHANGE
SFS2X.SFSEvent.PROXIMITY_LIST_UPDATE
<static> <constant> SFS2X.SFSEvent.USER_EXIT_ROOM
The userExitRoom event type, dispatched when one of the Rooms joined by the current user is left by another user, or by the current user himself.

This event is caused by a LeaveRoomRequest request; it might be fired or not depending on the Room configuration defined upon its creation (see the RoomSettings.events setting).

NOTE: if the Room is of type MMORoom, this event is fired when the current user leaves the Room only. For the other users leaving the Room it is substituted by the proximityListUpdate event.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
user{SFSUser}An object representing the user who left the Room.
room{SFSRoom}An object representing the Room that was left by a user.

The following example shows how to handle this event type:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.USER_EXIT_ROOM, onUserExitRoom, this);
}

function onUserExitRoom(evtParams)
{
	var room = evtParams.room;
	var user = evtParams.user;
	
	console.log("User " + user.name + " just left Room " + room.name);
}
See also:
SFS2X.Requests.System.LeaveRoomRequest
SFS2X.Requests.RoomSettings#events
SFS2X.Entities.SFSUser
SFS2X.Entities.SFSRoom
SFS2X.Entities.MMORoom
SFS2X.SFSEvent.USER_ENTER_ROOM
SFS2X.SFSEvent.USER_COUNT_CHANGE
SFS2X.SFSEvent.PROXIMITY_LIST_UPDATE
<static> <constant> SFS2X.SFSEvent.USER_FIND_RESULT
The userFindResult event type, dispatched when a users search is completed.

This event is fired in response to the FindUsersRequest request to return the search result.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
users{Array}A list of SFSUser objects representing the users matching the search criteria. If no user is found, the list is empty.

The following example looks for all the users whose "age" User Variable is greater than 29:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.USER_FIND_RESULT, onUserFindResult, this);
	
	// Create a matching expression to find users with an "age" variable greater than 29:
	var exp = new SFS2X.Entities.Match.MatchExpression("age", SFS2X.Entities.Match.NumberMatch.GREATER_THAN, 29);
	
	// Find the users
	sfs.send(new SFS2X.Requests.System.FindUserRequest(exp));
}

function onUserFindResult(evtParams)
{
	console.log("Users found: " + evtParams.users);
}
See also:
SFS2X.Requests.System.FindUsersRequest
SFS2X.Entities.SFSUser
<static> <constant> SFS2X.SFSEvent.USER_VARIABLES_UPDATE
The userVariablesUpdate event type, dispatched when a User Variable is updated.

This event is caused by the SetUserVariablesRequest request sent by a user in one of the Rooms joined by the current user.

The object passed to the listener contains the following parameters:
PropertyTypeDescription
user{SFSUser}An object representing the user who updated his own User Variables.
changedVars{Array}The list of names of the User Variables that were changed (or created for the first time).

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

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.USER_VARIABLES_UPDATE, onUserVarsUpdate, this);
	
	// Create some User Variables
	var userVars = [];
	userVars.push(new SFS2X.Entities.Variables.SFSUserVariable("avatarType", "SwedishCook"));
	userVars.push(new SFS2X.Entities.Variables.SFSUserVariable("country", "Sweden"));
	userVars.push(new SFS2X.Entities.Variables.SFSUserVariable("x", 10));
	userVars.push(new SFS2X.Entities.Variables.SFSUserVariable("y", 5));
	
	sfs.send(new SFS2X.Requests.System.SetUserVariablesRequest(userVars));
}

function onUserVarsUpdate(evtParams)
{
	var changedVars = evtParams.changedVars;
	var user = evtParams.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
		...
	}
}
See also:
SFS2X.Requests.System.SetUserVariablesRequest
SFS2X.Entities.SFSUser