Class SFS2X.Entities.Variables.SFSRoomVariable

The Room Variable entity representation on the client.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a new SFSRoomVariable instance.

Field Summary

Method Summary

Class Detail

SFS2X.Entities.Variables.SFSRoomVariable(name, value, type)
Creates a new SFSRoomVariable instance.

A SFSRoomVariable is a custom value attached to a SFSRoom object that gets automatically synchronized between client and server on every change.

Room Variables are particularly useful to store custom Room data such as a game status and other Room-level informations. They can be set by means of the SetRoomVariablesRequest request; they support the following data types (also nested): Boolean, Number, String, Object, Array. A Room Variable can also be null.

Room Variables also support a number of specific flags:
- Private: a private Room Variable can only be modified by its creator.
- Persistent: a persistent Room Variable will continue to exist even if its creator has left the Room (but will be deleted when the creator will get disconnected).
- Global: a global Room Variable will fire update events not only to all users in the Room, but also to all users in the Group to which the Room belongs (NOTE: this flag is not available on the client-side because clients are not allowed to create global Room Variables).

Parameters:
{String} name
The name of the Room Variable.
{*} value
The value of the Room Variable; valid data types are: Boolean, Number, String, Object, Array. The value can also be null.
{Number} type Optional, Default: -1
The type id of the Room 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:
SFS2X.Entities.Variables.VariableType
SFS2X.Entities.SFSRoom
SFS2X.Requests.System.SetRoomVariablesRequest

Field Detail

{Boolean} isPersistent
Indicates whether this Room Variable is persistent or not. A persistent Room Variable continues to exist in the Room after the user who created it has left it and until he disconnects.

NOTE: setting the isPersistent property manually on an existing Room Variable returned by the API has no effect on the server and can disrupt the API functioning. This flag can be set when the Room Variable object is created using the constructor.

{Boolean} isPrivate
Indicates whether this Room Variable is private or not. A private Room Variable is visible to all users in the same Room, but it can be modified only by its owner (the user that created it).

NOTE: setting the isPrivate property manually on an existing Room Variable returned by the API has no effect on the server and can disrupt the API functioning. This flag can be set when the Room Variable object is created using the constructor.

Method Detail

  • {String} toString()
    Returns a string that contains the Room Variable name, type, value and isPrivate flag.
    Returns:
    {String} The string representation of the SFSRoomVariable object.