Class SFSRoomVariable
- All Implemented Interfaces:
RoomVariable,Variable
Room Variables are particularly useful to store custom Room data such as a game state, and other Room-level information. Room Variables can be set by means of the SetRoomVariablesRequest request.
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 continues to exist after its creator has left the Room (but is deleted when the creator disconnects or logs out).
- Global: a global Room Variable sends update events to all users in the Room Group where the Room belongs (NOTE: global Room Variables can only be created on the server side, for security reasons, e.g. avoid client spam).
- See Also:
-
Field Summary
Fields inherited from class sfs3.client.entities.variables.BaseVariable
name, type, val -
Constructor Summary
ConstructorsConstructorDescriptionSFSRoomVariable(String name, Object val) Creates a new Room VariableSFSRoomVariable(String name, Object value, VariableType type) Types are normally auto-detected. -
Method Summary
Modifier and TypeMethodDescriptionstatic RoomVariablefromSFSArray(ISFSArray sfsa) booleanIndicates whether this Room Variable is persistent or not.booleanIndicates whether this Room Variable is private or not.voidsetPersistent(boolean persistent) voidsetPrivate(boolean setPrivate) PrivatetoString()Returns a string that contains the Room Variable name, type, value and isPrivate flag.Methods inherited from class sfs3.client.entities.variables.BaseVariable
getBoolValue, getByteValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getName, getSFSArrayValue, getSFSObjectValue, getSFSVector2Value, getSFSVector3Value, getShortValue, getStringValue, getType, getValue, isNull, populateArrayWithValue, setValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface sfs3.client.entities.variables.Variable
getBoolValue, getByteValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getName, getSFSArrayValue, getSFSObjectValue, getSFSVector2Value, getSFSVector3Value, getShortValue, getStringValue, getType, getValue, isNull
-
Constructor Details
-
SFSRoomVariable
Creates a new Room Variable -
SFSRoomVariable
Types are normally auto-detected. Please seeSFSRoomVariable(String, Object)- Parameters:
name- name of the Room Variable.value- value of the Room Variabletype- type of the Room Variable- See Also:
-
-
Method Details
-
fromSFSArray
- Internal
-
isPersistent
public boolean isPersistent()Description copied from interface:RoomVariableIndicates 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 by the developer only (using the new keyword).
- Specified by:
isPersistentin interfaceRoomVariable
-
isPrivate
public boolean isPrivate()Description copied from interface:RoomVariableIndicates whether this Room Variable is private or not. A private Room Variable can be modified by its owner only (the user that created it).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 by the developer only (using the new keyword).
- Specified by:
isPrivatein interfaceRoomVariable
-
setPrivate
public void setPrivate(boolean setPrivate) - Specified by:
setPrivatein interfaceRoomVariable
-
setPersistent
public void setPersistent(boolean persistent) - Specified by:
setPersistentin interfaceRoomVariable
-
toSFSArray
Description copied from interface:VariablePrivate- Specified by:
toSFSArrayin interfaceVariable- Overrides:
toSFSArrayin classBaseVariable
-
toString
Returns a string that contains the Room Variable name, type, value and isPrivate flag.- Overrides:
toStringin classBaseVariable- Returns:
- The string representation of the SFSRoomVariable object.
-