Class SFS2X.Entities.Variables.SFSRoomVariable
The Room Variable entity representation on the client.
Constructor Attributes | Constructor Name and Description |
---|---|
SFS2X.Entities.Variables.SFSRoomVariable(name, value, type)
Creates a new SFSRoomVariable instance.
|
Field Summary
Method Summary
Class Detail
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.
Field Detail
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.
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.