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

BuddyVariables are custom values attached to any Buddy in a BuddyList. More...

#include <SFSBuddyVariable.h>

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

Public Member Functions

 SFSBuddyVariable (string name, boost::shared_ptr< void > val, long int type)
 
 SFSBuddyVariable (boost::shared_ptr< string > name, boost::shared_ptr< void > val, long int type)
 
 SFSBuddyVariable (string name, boost::shared_ptr< long int > val)
 <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.
 
virtual boost::shared_ptr< ISFSArrayToSFSArray ()
 <exclude>
 
boost::shared_ptr< string > ToString ()
 Returns a string that contains the Buddy Variable name, type and value. More...
 
- 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

BuddyVariables are custom values attached to any Buddy in a BuddyList.

They work with the same principle of the User/Room Variables.
The only difference is the logic by which they get propagated to other Users. While RoomVariables are broadcast to all clients in the same Room, BuddyVariables are updated to all Users who have the BuddyVariable owner in their BuddyLists.

BuddyVariables support basic data types and nested complex objects:

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

Also there is a special convention that allows certain Variables to be "offline" Buddy Variables.
All variable names starting with a dollar sign ($) will set the BuddyVariable as persistent and make them available at any time whether the owner is online or not.

See also
SFSBuddy, Requests.SetBuddyVariablesRequest, Core.SFSBuddyEvent.BUDDY_VARIABLES_UPDATE

Constructor & Destructor Documentation

◆ SFSBuddyVariable() [1/2]

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

◆ SFSBuddyVariable() [2/2]

Sfs2X::Entities::Variables::SFSBuddyVariable::SFSBuddyVariable ( boost::shared_ptr< 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

◆ ToString()

boost::shared_ptr< string > Sfs2X::Entities::Variables::SFSBuddyVariable::ToString ( )

Returns a string that contains the Buddy Variable name, type and value.

Returns
The string representation of the Sfs2X.Entities.Variables.SFSBuddyVariable object.