Method

new SFSUserVariable(name, value[, type])

Creates a new SFSUserVariable instance.

A SFSUserVariable is a custom value attached to a SFSUser 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, number, string, SFSObject, SFSArray. A User Variable can also be null.

Parameters

Name Type Optional Description

name

 

 

The name of the User Variable.

value

 

 

The value of the User Variable; it can also be null.

type

 

Yes

The type id 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.

Defaults to -1.

Extends
BaseVariable
See also
VariableType
SFSUser
SetUserVariablesRequest

Properties

read-only

isNull  unknown

Indicates if the Variable is null.

Inherited from
BaseVariable#isNull

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 after the User Variable object is created using the constructor only.

read-only

name  unknown

Indicates the name of this variable.

Inherited from
BaseVariable#name
read-only

type  unknown

Indicates the type of this Variable. Possibly returned strings are: null, boolean, int, double, string, SFSObject, SFSArray.

Inherited from
BaseVariable#type
read-only

value  unknown

Returns the value of this variable.

Inherited from
BaseVariable#value

Method

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.