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

The SFSUserVariable object represents a SmartFoxServer User Variable entity on the client. More...

#include <SFSUserVariable.h>

Inheritance diagram for Sfs2X::Entities::Variables::SFSUserVariable:
Sfs2X::Entities::Variables::BaseVariable Sfs2X::Entities::Variables::UserVariable Sfs2X::Entities::Variables::Variable Sfs2X::Entities::Variables::Variable

Public Member Functions

 SFSUserVariable (string name, boost::shared_ptr< long int > val)
 Contructor for SFSUserVariable More...
 
 SFSUserVariable (string name, boost::shared_ptr< void > val, long int type)
 
bool IsPrivate ()
 Indicates whether this User Variable is private or not. More...
 
void IsPrivate (bool value)
 Indicates whether this User Variable is private or not. More...
 
virtual boost::shared_ptr< string > Name ()
 Indicates the name of this variable.
 
virtual VariableType Type ()
 Indicates the type of this variable.
 
virtual boost::shared_ptr< void > Value ()
 Returns the untyped value of this variable.
 
virtual boost::shared_ptr< bool > GetBoolValue ()
 Retrieves the value of a boolean variable.
 
virtual boost::shared_ptr< long int > GetIntValue ()
 Retrieves the value of an integer variable.
 
virtual boost::shared_ptr< double > GetDoubleValue ()
 Retrieves the value of a double precision variable.
 
virtual boost::shared_ptr< string > GetStringValue ()
 Retrieves the value of a string variable.
 
virtual boost::shared_ptr< ISFSObjectGetSFSObjectValue ()
 Retrieves the value of a SFSObject variable.
 
virtual boost::shared_ptr< ISFSArrayGetSFSArrayValue ()
 Retrieves the value of a SFSArray variable.
 
virtual bool IsNull ()
 Indicates if the variable is null.
 
virtual boost::shared_ptr< ISFSArrayToSFSArray ()
 <exclude>
 
- 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...
 

Static Public Member Functions

static boost::shared_ptr< SFSUserVariablenewPrivateVariable (string name, boost::shared_ptr< long int > val)
 Creates a new private User Variable. More...
 

Detailed Description

The SFSUserVariable object represents a SmartFoxServer User Variable entity on the client.

This is a custom value attached to a User object that gets automatically synchronized between client and server on every change.

User Variables are particularly useful to store custom user data that must be "visible" to the other users, such as a profile, a score, a status message, etc. User Variables can be set by means of the Sfs2X.Requests.SetUserVariablesRequest request; they support the data types listed in the

See also
VariableType

class (also nested). A User Variable can also be null.

User Variables can be 'private' (starting from SFS2X v2.12 with client API v1.7): this flag allows to limit the visibility of variables to their owner only. In other words User Variables marked as private are not sent to other users, even if located in the same Room.

See also
Sfs2X.Entities.User, Sfs2X.Requests.SetUserVariablesRequest

Constructor & Destructor Documentation

◆ SFSUserVariable() [1/2]

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

Contructor for SFSUserVariable

<overrides>

</overrides>

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

◆ SFSUserVariable() [2/2]

Sfs2X::Entities::Variables::SFSUserVariable::SFSUserVariable ( 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

Member Function Documentation

◆ IsPrivate() [1/2]

bool Sfs2X::Entities::Variables::SFSUserVariable::IsPrivate ( )
virtual

Indicates whether this User Variable is private or not.

A private User Variable is visible only to its owner; any changes made to the variable will be transmitted to the owner only.

NOTE: setting this property manually on an existing User Variable returned by the API has no effect on the server and can disrupt the API functioning. This flag can be set when the User Variable object is created by the developer only (using the new keyword).

Implements Sfs2X::Entities::Variables::UserVariable.

◆ IsPrivate() [2/2]

void Sfs2X::Entities::Variables::SFSUserVariable::IsPrivate ( bool  value)
virtual

Indicates whether this User Variable is private or not.

A private User Variable is visible only to its owner; any changes made to the variable will be transmitted to the owner only.

NOTE: setting this property manually on an existing User Variable returned by the API has no effect on the server and can disrupt the API functioning. This flag can be set when the User Variable object is created by the developer only (using the new keyword).

Implements Sfs2X::Entities::Variables::UserVariable.

◆ newPrivateVariable()

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

Creates a new private User Variable.

Private User Variables are not broadcast to other users: they are only visible on the server side and in the owner's client application.

Parameters
nameThe name of the User Variable.
valThe value of the User Variable.