Package | com.smartfoxserver.v2.entities.variables |
Class | public class SFSUserVariable |
Inheritance | SFSUserVariable BaseVariable Object |
Implements | UserVariable |
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
Property | Defined By | ||
---|---|---|---|
isPrivate : Boolean
Indicates whether this User Variable is private or not. | SFSUserVariable | ||
name : String [read-only]
Indicates the name of this variable. | BaseVariable | ||
type : String [read-only]
Indicates the type of this variable. | BaseVariable |
Method | Defined By | ||
---|---|---|---|
SFSUserVariable(name:String, value:*, type:int = -1)
Creates a new SFSUserVariable instance. | SFSUserVariable | ||
getBoolValue():Boolean
Retrieves the value of a boolean variable. | BaseVariable | ||
getDoubleValue():Number
Retrieves the value of a numeric variable. | BaseVariable | ||
getIntValue():int
Retrieves the value of an integer variable. | BaseVariable | ||
Retrieves the value of a SFSArray variable. | BaseVariable | ||
Retrieves the value of a SFSObject variable. | BaseVariable | ||
getStringValue():String
Retrieves the value of a string variable. | BaseVariable | ||
getValue():*
Retrieves the untyped value of this variable. | BaseVariable | ||
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 |
isPrivate | property |
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).
public function get isPrivate():Boolean
public function set isPrivate(value:Boolean):void
SFSUserVariable | () | Constructor |
public function SFSUserVariable(name:String, value:*, type:int = -1)
Creates a new SFSUserVariable instance.
Parametersname: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
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 .
|
SFSUserVariable |
toString | () | method |
public function toString():String
Returns a string that contains the User Variable name, type, value and isPrivate flag.
ReturnsString — The string representation of the SFSUserVariable object.
|