Inherits from SFSUserVariable : 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

Tasks

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:type:

the name of the variable

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

Parameters

name

the name of the variable

value

the variable value ( can be Boolean, int, Number, 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