SmartFoxServer 2X C++ API
Sfs2X::Entities::Variables::SFSRoomVariable Class Reference

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

#include <SFSRoomVariable.h>

Inheritance diagram for Sfs2X::Entities::Variables::SFSRoomVariable:
Sfs2X::Entities::Variables::BaseVariable Sfs2X::Entities::Variables::Variable

Public Member Functions

 SFSRoomVariable (string name, boost::shared_ptr< long int > val)
 
 SFSRoomVariable (string name, boost::shared_ptr< void > val, long int type)
 
boost::shared_ptr< ISFSArrayToSFSArray ()
 <exclude>
 
boost::shared_ptr< string > Name ()
 Indicates the name of this variable.
 
VariableType Type ()
 Indicates the type of this variable.
 
boost::shared_ptr< void > Value ()
 Returns the untyped value of this variable.
 
boost::shared_ptr< bool > GetBoolValue ()
 Retrieves the value of a boolean variable.
 
boost::shared_ptr< long int > GetIntValue ()
 Retrieves the value of an integer variable.
 
boost::shared_ptr< double > GetDoubleValue ()
 Retrieves the value of a double precision variable.
 
boost::shared_ptr< string > GetStringValue ()
 Retrieves the value of a string variable.
 
boost::shared_ptr< ISFSObjectGetSFSObjectValue ()
 Retrieves the value of a SFSObject variable.
 
boost::shared_ptr< ISFSArrayGetSFSArrayValue ()
 Retrieves the value of a SFSArray variable.
 
bool IsNull ()
 Indicates if the variable is null.
 
- Public Member Functions inherited from Sfs2X::Entities::Variables::BaseVariable
 BaseVariable (string name, boost::shared_ptr< void > val, long int type)
 Creates a new BaseVariable instance. More...
 
 BaseVariable (string name, boost::shared_ptr< long int > val)
 Creates a new BaseVariable instance. More...
 

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:

  • 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 also
SFSRoom, Requests.SetRoomVariablesRequest

Constructor & Destructor Documentation

◆ SFSRoomVariable() [1/2]

Sfs2X::Entities::Variables::SFSRoomVariable::SFSRoomVariable ( string  name,
boost::shared_ptr< long int >  val 
)

<overrides>

</overrides>

Parameters
namethe name of the variable
valthe variable value ( can be Boolean, int, Number, String, SFSObject, SFSArray )

◆ SFSRoomVariable() [2/2]

Sfs2X::Entities::Variables::SFSRoomVariable::SFSRoomVariable ( string  name,
boost::shared_ptr< void >  val,
long int  type 
)
Parameters
namethe name of the variable
valthe variable value ( can be Boolean, int, Number, String, SFSObject, SFSArray )
typeit's usually not necessary to pass this parameter as the variable value is auto-detected