SFS2X Objective-C API  1.7.13
iOS / macOS / tvOS
SFSRoomVariable Class Reference

#import <SFSRoomVariable.h>

Inherits BaseVariable, and <RoomVariable>.

Instance Methods

(id< ISFSArray >) - toSFSArray
 
- Instance Methods inherited from BaseVariable
(id) - initWithName:value:type:
 
(id) - getValue
 
(BOOL) - getBoolValue
 
(NSInteger) - getIntValue
 
(NSNumber *) - getDoubleValue
 
(NSString *) - getStringValue
 
(id< ISFSObject >) - getSFSObjectValue
 
(id< ISFSArray >) - getSFSArrayValue
 
(BOOL) - isNull
 

Class Methods

(id) + variableWithName:value:type:
 
(id) + variableWithName:value:
 
(id) + variableWithName:value:isPrivate:isPersistent:
 
(id< RoomVariable >) + fromSFSArray:
 

Protected Attributes

BOOL _isPersistent
 
BOOL _isPrivate
 
- Protected Attributes inherited from BaseVariable
NSString * _name
 
NSString * _type
 
id _value
 

Properties

BOOL isPersistent
 
BOOL isPrivate
 
- Properties inherited from BaseVariable
NSString * name
 
NSString * type
 

Detailed Description

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:

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 also
SFSRoom
SetRoomVariablesRequest

Method Documentation

◆ variableWithName:value:

+ (id) variableWithName: (NSString *)  name
value: (id)  value 
Parameters
namethe name of the variable
valuethe variable value ( can be BOOL, Integer, Double, String, SFSObject, SFSArray )

Reimplemented from BaseVariable.

◆ variableWithName:value:isPrivate:isPersistent:

+ (id) variableWithName: (NSString *)  name
value: (id)  value
isPrivate: (BOOL)  priv
isPersistent: (BOOL)  pers 
Parameters
namethe name of the variable
valuethe variable value ( can be BOOL, Integer, Double, String, SFSObject, SFSArray )
privindicates whether the variable can be modified by other users or not
persindicates whether the variable is removed from the Room when the user leaves (YES = variable is not removed)

◆ variableWithName:value:type:

+ (id) variableWithName: (NSString *)  name
value: (id)  value
type: (NSInteger)  type 
Parameters
namethe name of the variable
valuethe 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

Reimplemented from BaseVariable.

Property Documentation

◆ isPersistent

- (BOOL) isPersistent
readwritenonatomicassign

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

◆ isPrivate

- (BOOL) isPrivate
readwritenonatomicassign

Checks if the variable is private.

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