Inherits from BaseVariable : NSObject
Conforms to RoomVariable
Declared in SFSRoomVariable.h
SFSRoomVariable.m

Overview

The RoomVariable class is used to represent variables maintained on the Server side and automatically updated to the clients.

They are particularly useful to “attach” any custom data to each Room such as the current game status and other Room-specific properties etc…

RoomVariables support basic data types and nested complex objects:

  • Null
  • Bool
  • Int
  • Double
  • String
  • SFSObject
  • SFSArray

RoomVariables also support different flags:

  • Private: a private variable can only be modified by its creator
  • Persistent: a persistent variable will continue to exist even if its creator has left the room.
  • Global: a global variable will fire updates not only to all Users in the Room but also to all Users in the Room Group

See SFSRoom, SetRoomVariablesRequest

Properties

isPersistent

Checks if the variable is persistent.

@property (nonatomic, readwrite) BOOL isPersistent

Discussion

Checks if the variable is persistent.

A persistent RoomVariable continues to exist in a Room after the User has left it and until he disconnects

Declared In

SFSRoomVariable.h

isPrivate

Checks if the variable is private.

@property (nonatomic, readwrite) BOOL isPrivate

Discussion

Checks if the variable is private.

A private RoomVariable is only modifiable by its owner (the user that created it)

Declared In

SFSRoomVariable.h

Class Methods

variableWithName:value:

the name of the variable

+ (id)variableWithName:(NSString *)name value:(id)value

Parameters

name

the name of the variable

value

the variable value ( can be BOOL, Integer, Double, String, SFSObject, SFSArray )

Declared In

SFSRoomVariable.h

variableWithName:value:isPrivate:isPersistent:

the name of the variable

+ (id)variableWithName:(NSString *)name value:(id)value isPrivate:(BOOL)priv isPersistent:(BOOL)pers

Parameters

name

the name of the variable

value

the variable value ( can be BOOL, Integer, Double, String, SFSObject, SFSArray )

isPrivate

indicates whether the variable can be modified by other users or not

isPersistent

indicates whether the variable is removed from the Room when the user leaves (YES = variable is not removed)

Declared In

SFSRoomVariable.h

variableWithName:value:type:

the name of the variable

+ (id)variableWithName:(NSString *)name value:(id)value type:(NSInteger)type

Parameters

name

the name of the variable

value

the variable value ( can be BOOL, Integer, Double, String, SFSObject, SFSArray )

type

(optional -1) it’s usually not necessary to pass this parameter as the variable value is auto-detected

Declared In

SFSRoomVariable.h