Packagecom.smartfoxserver.v2.entities
Classpublic class SFSUser
InheritanceSFSUser Inheritance Object
Implements User

The SFSUser object represents a client logged in SmartFoxServer.

The SmartFoxServer 2X client API are 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


Public Properties
 PropertyDefined By
  aoiEntryPoint : Vec3D
Returns the entry point of this user in the current user's AoI.
SFSUser
  id : int
[read-only] Indicates the id of this user.
SFSUser
  isItMe : Boolean
[read-only] Indicates if this User object represents the current client.
SFSUser
  isPlayer : Boolean
[read-only] Indicates whether this user is a player (playerId greater than 0) in the last joined Room or not.
SFSUser
  isSpectator : Boolean
[read-only] Indicates whether this user is a spectator (playerId lower than 0) in the last joined Room or not.
SFSUser
  name : String
[read-only] Indicates the name of this user.
SFSUser
  playerId : int
[read-only] Returns the id of this user as a player in a Game Room.
SFSUser
  privilegeId : int
Returns the id which identifies the privilege level of this user.
SFSUser
  properties : Object
Defines a generic utility object that can be used to store custom user data.
SFSUser
  userManager : IUserManager
Returns a reference to the User Manager which manages this user.
SFSUser
Public Methods
 MethodDefined By
  
SFSUser(id:int, name:String, isItMe:Boolean = false)
Creates a new SFSUser instance.
SFSUser
  
containsVariable(name:String):Boolean
Indicates whether this user has the specified User Variable set or not.
SFSUser
  
getPlayerId(room:Room):int
Returns the playerId value of this user in the passed Room.
SFSUser
  
Retrieves a User Variable from its name.
SFSUser
  
getVariables():Array
Retrieves all the User Variables of this user.
SFSUser
  
isAdmin():Boolean
Indicates whether this user logged in as an administrator or not.
SFSUser
  
isGuest():Boolean
Indicates whether this user logged in as a guest or not.
SFSUser
  
isJoinedInRoom(room:Room):Boolean
Indicates whether this user joined the passed Room or not.
SFSUser
  
isModerator():Boolean
Indicates whether this user logged in as a moderator or not.
SFSUser
  
isPlayerInRoom(room:Room):Boolean
Indicates whether this user is a player (playerId greater than 0) in the passed Room or not.
SFSUser
  
isSpectatorInRoom(room:Room):Boolean
Indicates whether this user is a spectator (playerId lower than 0) in the passed Room or not.
SFSUser
  
isStandardUser():Boolean
Indicates whether this user logged in as a standard user or not.
SFSUser
  
toString():String
Returns a string that contains the user id, name and a boolean indicating if the SFSUser object represents the current client.
SFSUser
Property Detail
aoiEntryPointproperty
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 SFSEvent.PROXIMITY_LIST_UPDATE 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.


Implementation
    public function get aoiEntryPoint():Vec3D
    public function set aoiEntryPoint(value:Vec3D):void
idproperty 
id:int  [read-only]

Indicates the id of this user. It is unique and it is generated by the server when the user is created.


Implementation
    public function get id():int
isItMeproperty 
isItMe:Boolean  [read-only]

Indicates if this User object represents the current client.


Implementation
    public function get isItMe():Boolean
isPlayerproperty 
isPlayer:Boolean  [read-only]

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.


Implementation
    public function get isPlayer():Boolean
isSpectatorproperty 
isSpectator:Boolean  [read-only]

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.


Implementation
    public function get isSpectator():Boolean
nameproperty 
name:String  [read-only]

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


Implementation
    public function get name():String
playerIdproperty 
playerId:int  [read-only]

Returns the id of this user as a player in a Game Room.

This property differs from id property and it used to indicate which player number is assigned to a user inside a Game Room. For example, in a Game Room for 5 players the first client joining it will have playerId equal to 1, the second will have it equal to 2 and so forth. When a user leaves the Room the player slot is freed up and the next user joining the Room will take it.

The playerId property applies to Game Rooms only; in standard Rooms it is always 0. Also, in Game Rooms a playerId value lower than 0 indicates that the user is a spectator.

If the user is inside multiple Game Rooms at the same time, a different playerId value will be assigned to him in each Room. In this case this property returns the value corresponding to the last joined Room; in order to obtain the playerId value in a specific Room, use the getPlayerId() method.


Implementation
    public function get playerId():int
privilegeIdproperty 
privilegeId:int

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.


Implementation
    public function get privilegeId():int
    public function set privilegeId(value:int):void
propertiesproperty 
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.


Implementation
    public function get properties():Object
    public function set properties(value:Object):void
userManagerproperty 
userManager:IUserManager

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

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


Implementation
    public function get userManager():IUserManager
    public function set userManager(value:IUserManager):void
Constructor Detail
SFSUser()Constructor
public function SFSUser(id:int, name:String, isItMe:Boolean = false)

Creates a new SFSUser instance.

NOTE: developers never istantiate a SFSUser manually: this is done by the SmartFoxServer 2X API internally.

Parameters
id:int — The user id.
 
name:String — The user name.
 
isItMe:Boolean (default = false) — If true, the user being created corresponds to the current client.
Method Detail
containsVariable()method
public function containsVariable(name:String):Boolean

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

Parameters

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

Returns
Booleantrue if a User Variable with the passed name is set for this user.
getPlayerId()method 
public function getPlayerId(room:Room):int

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

Parameters

room:Room — The Room object representing the Room to retrieve the player id from.

Returns
int — The playerId of this user in the passed Room.
getVariable()method 
public function getVariable(name:String):UserVariable

Retrieves a User Variable from its name.

Parameters

name:String — The name of the User Variable to be retrieved.

Returns
UserVariable — The UserVariable object representing the User Variable, or null if no User Variable with the passed name is associated with this user.
getVariables()method 
public function getVariables():Array

Retrieves all the User Variables of this user.

Returns
Array — The list of UserVariable objects associated with the user.
isAdmin()method 
public function isAdmin():Boolean

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

Returns
Booleantrue if this user is an administrator.
isGuest()method 
public function isGuest():Boolean

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

Returns
Booleantrue if this user is a guest.
isJoinedInRoom()method 
public function isJoinedInRoom(room:Room):Boolean

Indicates whether this user joined the passed Room or not.

Parameters

room:Room — The Room object representing the Room where to check the user presence.

Returns
Booleantrue if this user is inside the passed Room.
isModerator()method 
public function isModerator():Boolean

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

Returns
Booleantrue if this user is a moderator.
isPlayerInRoom()method 
public function isPlayerInRoom(room: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 Room at a time only, use the isPlayer property.

Parameters

room:Room — The Room object representing the Room where to check if this user is a player.

Returns
Booleantrue if this user is a player in the passed Room.
isSpectatorInRoom()method 
public function isSpectatorInRoom(room: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 Room at a time only, use the isSpectator property.

Parameters

room:Room — The Room object representing the Room where to check if this user is a spectator.

Returns
Booleantrue if this user is a spectator in the passed Room.
isStandardUser()method 
public function isStandardUser():Boolean

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

Returns
Booleantrue if this user is a standard user.
toString()method 
public function 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.