new SFSUser()

Developers never istantiate the SFSUser class: this is done internally by the SmartFoxServer 2X API.

The SFSUser object represents a client logged in SmartFoxServer 2X. The client API is not aware of all the clients (users) connected to the server, but only of those that are in the same Rooms joined by the current client; this reduces the traffic between the client and the server considerably. In order to interact with other users the client should join other Rooms or use the Buddy List system to keep track of and interact with friends.

See also
SmartFox#userManager
SmartFox#buddyManager
JoinRoomRequest

Properties

read-only

aoiEntryPoint  Vec3D

Returns the entry point of this user in the current user's AoI.

The returned coordinates are those that the user had when his presence in the current user's Area of Interest was last notified by a proximityListUpdate event. This field is populated only if the user joined a Room of type MMORoom and this is configured to receive such data from the server.

See also
MMORoomSettings#sendAOIEntryPoint
SFSEvent.PROXIMITY_LIST_UPDATE
read-only

id  number

Indicates the id of this user. The id is unique and it is generated by the server when the user logs in.

read-only

isAdmin  boolean

Indicates whether this user logged in as an administrator or not. Administrator users have the privilegeId property set to UserPrivileges.ADMINISTRATOR.

See also
SFSUser#isGuest
SFSUser#isStandardUser
SFSUser#isModerator
SFSUser#privilegeId
UserPrivileges.ADMINISTRATOR
read-only

isGuest  boolean

Indicates whether this user logged in as a guest or not. Guest users have the privilegeId property set to UserPrivileges.GUEST.

See also
SFSUser#isStandardUser
SFSUser#isModerator
SFSUser#isAdmin
SFSUser#privilegeId
UserPrivileges.GUEST
read-only

isItMe  boolean

Indicates if this SFSUser object represents the current client.

See also
SmartFox#mySelf
read-only

isModerator  boolean

Indicates whether this user logged in as a moderator or not. Moderator users have the privilegeId property set to UserPrivileges.MODERATOR.

See also
SFSUser#isGuest
SFSUser#isStandardUser
SFSUser#isAdmin
SFSUser#privilegeId
UserPrivileges.MODERATOR
read-only

isPlayer  boolean

Indicates whether this user is a player (playerId greater than 0) in the last joined Room or not. Non-Game Rooms always return false.

If the user is inside multiple Game Rooms at the same time, use the isPlayerInRoom() method.

See also
SFSUser#getPlayerId
SFSUser#isPlayerInRoom
SFSUser#isSpectator
read-only

isSpectator  boolean

Indicates whether this user is a spectator (playerId lower than 0) in the last joined Room or not. Non-Game Rooms always return false.

If the user is inside multiple Game Rooms at the same time, use the isSpectatorInRoom() method.

See also
SFSUser#getPlayerId
SFSUser#isSpectatorInRoom
SFSUser#isPlayer
read-only

isStandardUser  boolean

Indicates whether this user logged in as a standard user or not. Standard users have the privilegeId property set to UserPrivileges.STANDARD.

See also
SFSUser#isGuest
SFSUser#isModerator
SFSUser#isAdmin
SFSUser#privilegeId
UserPrivileges.STANDARD
read-only

name  string

Indicates the name of this user. Two users in the same Zone can't have the same name.

read-only

privilegeId  number

Returns the id which identifies the privilege level of this user. Privileges are assigned to the user by the server when the user logs in.

See also
UserPrivileges

properties  object

Defines a generic utility object that can be used to store custom user data. The values added to this object are for client-side use only and are never transmitted to the server or to the other clients.

Methods

containsVariable(varName) → boolean

Indicates whether this user has the specified User Variable set or not.

Parameter

Name Type Optional Description

varName

string

 

The name of the User Variable whose existance must be checked.

See also
SFSUserVariable
Returns

boolean true if a User Variable with the passed name is set for this user.

getPlayerId(room) → number

Returns the playerId value of this user in the passed Room. See the playerId property description for more informations.

Parameter

Name Type Optional Description

room

SFSRoom

 

The SFSRoom object representing the Room to retrieve the player id from.

Returns

number The playerId of this user in the passed Room.

getUserManager() → SFSUserManager

Returns a reference to the User Manager which manages this user.

Returns

SFSUserManager The User Manager to which this user is associated.

getVariable(varName) → SFSUserVariable

Retrieves a User Variable from its name.

Parameter

Name Type Optional Description

varName

string

 

The name of the User Variable to be retrieved.

See also
SFSUser#getVariables
SetUserVariablesRequest
Returns

SFSUserVariable The object representing the User Variable, or undefined if no User Variable with the passed name is associated with this user.

getVariables() → Array of SFSUserVariable

Retrieves all the User Variables of this user.

See also
SFSUser#getVariable
SetUserVariablesRequest
Returns

Array of SFSUserVariable The list of SFSUserVariable objects associated with the user.

isJoinedInRoom(room) → boolean

Indicates whether this user joined the passed Room or not.

Parameter

Name Type Optional Description

room

SFSRoom

 

The SFSRoom object representing the Room where to check the user presence.

Returns

boolean true if this user is inside the passed Room.

isPlayerInRoom(room) → boolean

Indicates whether this user is a player (playerId greater than 0) in the passed Room or not. Non-Game Rooms always return false.

If a user can join one Game Rooms at a time only, use the isPlayer property.

Parameter

Name Type Optional Description

room

SFSRoom

 

The SFSRoom object representing the Room where to check if this user is a player.

See also
SFSUser#getPlayerId
SFSUser#isPlayer
SFSUser#isSpectatorInRoom
Returns

boolean true if this user is a player in the passed Room.

isSpectatorInRoom(room) → boolean

Indicates whether this user is a spectator (playerId lower than 0) in the passed Room or not. Non-Game Rooms always return false.

If a user can join one Game Rooms at a time only, use the isSpectator property.

Parameter

Name Type Optional Description

room

SFSRoom

 

The SFSRoom object representing the Room where to check if this user is a spectator.

See also
SFSUser#getPlayerId
SFSUser#isSpectator
SFSUser#isPlayerInRoom
Returns

boolean true if this user is a spectator in the passed Room.

toString() → string

Returns a string that contains the user id, name and a boolean indicating if the SFSUser object represents the current client.

Returns

string The string representation of the SFSUser object.