Packagecom.smartfoxserver.v2.entities.variables
Classpublic class SFSUserVariable
InheritanceSFSUserVariable Inheritance BaseVariable Inheritance Object
Implements UserVariable

The SFSUserVariable object represents a SmartFoxServer User Variable entity on the client. It is a custom value attached to a User object that gets automatically synchronized between client and server on every change.

User Variables are particularly useful to store custom user data that must be "visible" to the other users, such as a profile, a score, a status message, etc. User Variables can be set by means of the SetUserVariablesRequest request; they support the following data types (also nested): Boolean, int, Number, String, SFSObject, SFSArray. A User Variable can also be null.

User Variables can be 'private' (starting from SFS2X v2.12 with client API v1.7): this flag allows to limit the visibility of variables to their owner only. In other words User Variables marked as private are not sent to other users, even if located in the same Room.

See also

User
SetUserVariablesRequest


Public Properties
 PropertyDefined By
  isPrivate : Boolean
Indicates whether this User Variable is private or not.
SFSUserVariable
 Inheritedname : String
[read-only] Indicates the name of this variable.
BaseVariable
 Inheritedtype : String
[read-only] Indicates the type of this variable.
BaseVariable
Public Methods
 MethodDefined By
  
SFSUserVariable(name:String, value:*, type:int = -1)
Creates a new SFSUserVariable instance.
SFSUserVariable
 Inherited
getBoolValue():Boolean
Retrieves the value of a boolean variable.
BaseVariable
 Inherited
Retrieves the value of a numeric variable.
BaseVariable
 Inherited
Retrieves the value of an integer variable.
BaseVariable
 Inherited
Retrieves the value of a SFSArray variable.
BaseVariable
 Inherited
Retrieves the value of a SFSObject variable.
BaseVariable
 Inherited
Retrieves the value of a string variable.
BaseVariable
 Inherited
Retrieves the untyped value of this variable.
BaseVariable
 Inherited
isNull():Boolean
Indicates if the variable is null.
BaseVariable
  
newPrivateVariable(name:String, value:*):SFSUserVariable
[static] Creates a new private User Variable.
SFSUserVariable
  
toString():String
Returns a string that contains the User Variable name, type, value and isPrivate flag.
SFSUserVariable
Property Detail
isPrivateproperty
isPrivate:Boolean

Indicates whether this User Variable is private or not. A private User Variable is visible only to its owner; any changes made to the variable will be transmitted to the owner only.

NOTE: setting the isPrivate property manually on an existing User Variable returned by the API has no effect on the server and can disrupt the API functioning. This flag can be set when the User Variable object is created by the developer only (using the new keyword).


Implementation
    public function get isPrivate():Boolean
    public function set isPrivate(value:Boolean):void
Constructor Detail
SFSUserVariable()Constructor
public function SFSUserVariable(name:String, value:*, type:int = -1)

Creates a new SFSUserVariable instance.

Parameters
name:String — The name of the User Variable.
 
value:* — The value of the User Variable; valid data types are: Boolean, int, Number, String, SFSObject, SFSArray. The value can also be null.
 
type:int (default = -1) — The type of the User Variable among those available in the VariableType class. Usually it is not necessary to pass this parameter, as the type is auto-detected from the value.

See also

Method Detail
newPrivateVariable()method
public static function newPrivateVariable(name:String, value:*):SFSUserVariable

Creates a new private User Variable. Private User Variables are not broadcast to other users: they are only visible on the server side and in the owner's client application.

Parameters

name:String — The name of the User Variable
 
value:* — The value of the User Variable; valid data types are: Boolean, int, Number, String, SFSObject, SFSArray. The value can also be null.

Returns
SFSUserVariable
toString()method 
public function toString():String

Returns a string that contains the User Variable name, type, value and isPrivate flag.

Returns
String — The string representation of the SFSUserVariable object.