SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
Loading...
Searching...
No Matches
sfs3::entities::SFSBuddyVariable Class Reference

The standard implementation of BuddyVariable: a custom value attached to a buddy in a buddy list, kept in sync between client and server on every change. More...

#include <SFSBuddyVariable.h>

Inheritance diagram for sfs3::entities::SFSBuddyVariable:
[legend]

Public Member Functions

bool isOffline () override
 Checks if this is a "offline" variable (persistent), which is available to other Users even when the client is not online.
std::string toString () override
Public Member Functions inherited from sfs3::entities::Variable
std::string name ()
virtual const VarDatavalue ()
 Returns the value of this variable, whatever its type.
virtual std::optional< bool > boolValue ()
virtual std::optional< uint8_t > byteValue ()
virtual std::optional< int16_t > shortValue ()
virtual std::optional< int32_t > intValue ()
virtual std::optional< int64_t > longValue ()
virtual std::optional< float > floatValue ()
virtual std::optional< double > doubleValue ()
virtual std::optional< std::string > stringValue ()
virtual std::shared_ptr< SFSObjectsfsObjectValue ()
virtual std::shared_ptr< SFSArraysfsArrayValue ()
virtual std::optional< SFSVector2vector2Value ()
virtual std::optional< SFSVector3vector3Value ()
virtual void setNull ()
 Clears the value of this variable.
virtual void setValue (VarData value)
 Sets the value of this variable.
virtual bool isNull ()

Static Public Attributes

static const std::string OFFLINE_PREFIX = "$"
 The prefix to be added to a Buddy Variable name to make it persistent.

Detailed Description

The standard implementation of BuddyVariable: a custom value attached to a buddy in a buddy list, kept in sync between client and server on every change.

Buddy Variables work with the same principle of the User and Room Variables. The only difference is the logic by which they get propagated to other users: while Room and User Variables are usually sent to all clients in the same Room, Buddy Variables are sent to the users who have the owner of the variable in their Buddy Lists.

A special convention allows Buddy Variables to be set as "offline": those are persistent values, made available to all users who have the owner in their Buddy Lists whether he is online or not. A Buddy Variable is made persistent by starting its name with a dollar sign, for example $avatarPic.

See also
SFSBuddyVariable::OFFLINE_PREFIX
BuddyVariable
Buddy
requests::buddy::SetBuddyVariablesRequest

Member Function Documentation

◆ isOffline()

bool sfs3::entities::SFSBuddyVariable::isOffline ( )
overridevirtual

Checks if this is a "offline" variable (persistent), which is available to other Users even when the client is not online.

There is no setter counterpart: a Buddy Variable is persistent by virtue of its own name starting with SFSBuddyVariable::OFFLINE_PREFIX, which is the only thing the server honours. Name it accordingly at construction to make it persistent.

Returns
true if the variable is persistent

Implements sfs3::entities::BuddyVariable.

◆ toString()

std::string sfs3::entities::SFSBuddyVariable::toString ( )
overridevirtual
Returns
the name, the type and the value of this variable as text, for logging and debugging

Reimplemented from sfs3::entities::Variable.

Member Data Documentation

◆ OFFLINE_PREFIX

const std::string sfs3::entities::SFSBuddyVariable::OFFLINE_PREFIX = "$"
inlinestatic

The prefix to be added to a Buddy Variable name to make it persistent.

A persistent Buddy Variable is made available to all users who have the owner in their Buddy Lists, whether that Buddy is online or not.


The documentation for this class was generated from the following files:
  • entities/SFSBuddyVariable.h
  • entities/SFSBuddyVariable.cpp