Class SFSRoomVariable

java.lang.Object
sfs3.client.entities.variables.BaseVariable
sfs3.client.entities.variables.SFSRoomVariable
All Implemented Interfaces:
RoomVariable, Variable

public class SFSRoomVariable extends BaseVariable implements RoomVariable
The SFSRoomVariable is a custom value attached to a Room object that is automatically synchronized between client and server on every change.

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:
  • Constructor Details

    • SFSRoomVariable

      public SFSRoomVariable(String name, Object val)
      Creates a new Room Variable
    • SFSRoomVariable

      public SFSRoomVariable(String name, Object value, VariableType type)
      Types are normally auto-detected. Please see SFSRoomVariable(String, Object)
      Parameters:
      name - name of the Room Variable.
      value - value of the Room Variable
      type - type of the Room Variable
      See Also:
  • Method Details

    • fromSFSArray

      public static RoomVariable fromSFSArray(ISFSArray sfsa)
      Internal
    • isPersistent

      public boolean isPersistent()
      Description copied from interface: RoomVariable
      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 by the developer only (using the new keyword).

      Specified by:
      isPersistent in interface RoomVariable
    • isPrivate

      public boolean isPrivate()
      Description copied from interface: RoomVariable
      Indicates 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:
      isPrivate in interface RoomVariable
    • setPrivate

      public void setPrivate(boolean setPrivate)
      Specified by:
      setPrivate in interface RoomVariable
    • setPersistent

      public void setPersistent(boolean persistent)
      Specified by:
      setPersistent in interface RoomVariable
    • toSFSArray

      public ISFSArray toSFSArray()
      Description copied from interface: Variable
      Private
      Specified by:
      toSFSArray in interface Variable
      Overrides:
      toSFSArray in class BaseVariable
    • toString

      public String toString()
      Returns a string that contains the Room Variable name, type, value and isPrivate flag.
      Overrides:
      toString in class BaseVariable
      Returns:
      The string representation of the SFSRoomVariable object.