Class SFS2X.Entities.SFSUser

The representation of a client logged in SmartFoxServer.

Class Summary
Constructor Attributes Constructor Name and Description
 
SFS2X.Entities.SFSUser(id, name, isItMe)
Creates a new SFSUser instance.

Field Summary

Method Summary

Class Detail

SFS2X.Entities.SFSUser(id, name, isItMe)
Creates a new SFSUser instance.

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.

NOTE: developers never istantiate a SFSUser manually: this is done by the SmartFoxServer 2X API internally. Creating an instance and passing it to the API can disrupt its functioning.

Parameters:
{Number} id
The user id.
{String} name
The user name.
{Boolean} isItMe Optional, Default: false
If true, the user being created corresponds to the current client.
See also:
SFS2X.SmartFox#userManager
SFS2X.SmartFox#buddyManager
SFS2X.Requests.System.JoinRoomRequest

Field Detail

{Vec3D} aoiEntryPoint
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.

NOTE: setting the aoiEntryPoint property manually has no effect on the server and can disrupt the API functioning.

See also:
SFS2X.Requests.MMO.MMORoomSettings#sendAOIEntryPoint
SFS2X.SFSEvent.PROXIMITY_LIST_UPDATE
{Number} id
Indicates the id of this user. It is unique and it is generated by the server when the user is created.

NOTE: the id is unique and it is generated by the server when the user performs the login. Setting it manually has no effect on the server and can disrupt the API functioning.

{Boolean} isItMe
Indicates if this SFSUser object represents the current client.

NOTE: setting the isItMe property manually has no effect on the server and can disrupt the API functioning. This is set by the API automatically.

See also:
SFS2X.SmartFox#mySelf
{String} name
Indicates the name of this user. Two users in the same Zone can't have the same name.

NOTE: setting the name property manually has no effect on the server and can disrupt the API functioning. This must be set during the login process.

{Number} privilegeId
Returns the id which identifies the privilege level of this user.

NOTE: setting the privilegeId property manually has no effect on the server and can disrupt the API functioning. Privileges are assigned to the user by the server when the user logs in.

See also:
SFS2X.Entities.UserPrivileges
{Object} properties
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.

Method Detail

  • {Boolean} containsVariable(varName)
    Indicates whether this user has the specified User Variable set or not.
    Parameters:
    {String} varName
    The name of the User Variable whose existance must be checked.
    Returns:
    {Boolean} true if a User Variable with the passed name is set for this user.
  • {Number} getPlayerId(room)
    Returns the playerId value of this user in the passed Room. See the playerId property description for more informations.
    Parameters:
    {SFSRoom} room
    The SFSRoom object representing the Room to retrieve the player id from.
    Returns:
    {Number} The playerId of this user in the passed Room.
  • {UserManager} getUserManager()
    Returns a reference to the User Manager which manages this user.
    Returns:
    {UserManager} The User Manager to which this user is associated.
  • {SFSUserVariable} getVariable(varName)
    Retrieves a User Variable from its name.
    Parameters:
    {String} varName
    The name of the User Variable to be retrieved.
    Returns:
    {SFSUserVariable} The object representing the User Variable, or null if no User Variable with the passed name is associated with this user.
    See also:
    #getVariables
    SFS2X.Entities.Variables.SFSUserVariable
    SFS2X.Requests.System.SetUserVariablesRequest
  • {Array} getVariables()
    Retrieves all the User Variables of this user.
    Returns:
    {Array} The list of SFSUserVariable objects associated with the user.
    See also:
    SFS2X.Entities.Variables.SFSUserVariable
    #getVariable
  • {Boolean} isAdmin()
    Indicates whether this user logged in as an administrator or not. Administrator users have the privilegeId property set to UserPrivileges.ADMINISTRATOR.
    Returns:
    {Boolean} true if this user is an administrator.
    See also:
    #isGuest
    #isStandardUser
    #isModerator
    #privilegeId
    SFS2X.Entities.UserPrivileges.ADMINISTRATOR
  • {Boolean} isGuest()
    Indicates whether this user logged in as a guest or not. Guest users have the privilegeId property set to UserPrivileges.GUEST.
    Returns:
    {Boolean} true if this user is a guest.
    See also:
    #isStandardUser
    #isModerator
    #isAdmin
    #privilegeId
    SFS2X.Entities.UserPrivileges.GUEST
  • {Boolean} isJoinedInRoom(room)
    Indicates whether this user joined the passed Room or not.
    Parameters:
    {SFSRoom} room
    The SFSRoom object representing the Room where to check the user presence.
    Returns:
    {Boolean} true if this user is inside the passed Room.
  • {Boolean} isModerator()
    Indicates whether this user logged in as a moderator or not. Moderator users have the privilegeId property set to UserPrivileges.MODERATOR.
    Returns:
    {Boolean} true if this user is a moderator.
    See also:
    #isGuest
    #isStandardUser
    #isAdmin
    #privilegeId
    SFS2X.Entities.UserPrivileges.MODERATOR
  • {Boolean} isPlayer()
    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.

    Returns:
    {Boolean} true if this user is a player in the last joined Room.
    See also:
    #getPlayerId
    #isPlayerInRoom
    #isSpectator
  • {Boolean} isPlayerInRoom(room)
    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.

    Parameters:
    {SFSRoom} room
    The SFSRoom object representing the Room where to check if this user is a player.
    Returns:
    {Boolean} true if this user is a player in the passed Room.
    See also:
    #getPlayerId
    #isPlayer
    #isSpectatorInRoom
  • {Boolean} isSpectator()
    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.

    Returns:
    {Boolean} true if this user is a spectator in the last joined Room.
    See also:
    #getPlayerId
    #isSpectatorInRoom
    #isPlayer
  • {Boolean} isSpectatorInRoom(room)
    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.

    Parameters:
    {SFSRoom} room
    The SFSRoom object representing the Room where to check if this user is a spectator.
    Returns:
    {Boolean} true if this user is a spectator in the passed Room.
    See also:
    #getPlayerId
    #isSpectator
    #isPlayerInRoom
  • {Boolean} isStandardUser()
    Indicates whether this user logged in as a standard user or not. Standard users have the privilegeId property set to UserPrivileges.STANDARD.
    Returns:
    {Boolean} true if this user is a standard user.
    See also:
    #isGuest
    #isModerator
    #isAdmin
    #privilegeId
    SFS2X.Entities.UserPrivileges.STANDARD
  • {String} toString()
    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.