SmartFoxServer 2X C++ API
Sfs2X::Entities::SFSBuddy Class Reference

The SFSBuddy class represent a Buddy in the User's Buddy List More...

#include <SFSBuddy.h>

Inheritance diagram for Sfs2X::Entities::SFSBuddy:
Sfs2X::Entities::Buddy

Public Member Functions

long int Id ()
 The id of the Buddy More...
 
void Id (long int value)
 The id of the Buddy More...
 
bool IsBlocked ()
 Return true if the Buddy is blocked in the current Users' BuddyList More...
 
void IsBlocked (bool value)
 Return true if the Buddy is blocked in the current Users' BuddyList More...
 
bool IsTemp ()
 Return true if the Buddy is temporary (not persistent) More...
 
boost::shared_ptr< string > Name ()
 The name of the Buddy More...
 
bool IsOnline ()
 Return true if the User is online in the BuddyList system More...
 
boost::shared_ptr< string > State ()
 The current Buddy custom state (e.g. "Available", "Busy", etc...) More...
 
boost::shared_ptr< string > NickName ()
 An optional Buddy nickname More...
 
boost::shared_ptr< vector< boost::shared_ptr< BuddyVariable > > > Variables ()
 Obtain a list of BuddyVariables. More...
 
boost::shared_ptr< BuddyVariable > GetVariable (string varName)
 Get the BuddyVariable with the provided name. More...
 
boost::shared_ptr< vector< boost::shared_ptr< BuddyVariable > > > GetOfflineVariables ()
 Return a list of offline Buddy Variables More...
 
boost::shared_ptr< vector< boost::shared_ptr< BuddyVariable > > > GetOnlineVariables ()
 Return a list of non-persistent Buddy Variables More...
 
bool ContainsVariable (string varName)
 Return true if a BuddyVariable with the provided name exists More...
 

Detailed Description

The SFSBuddy class represent a Buddy in the User's Buddy List

Overview

The SFSBuddy class represent a Buddy in the User's Buddy List. Each Buddy has several properties:

  • name: the name of the Buddy, corresponds to the User name
  • nickname: an optional nickname (default = null)
  • isOnline: whether the Buddy is online in the Buddy system or not
  • state: a string representing a "state message", such as: Available, Busy...
  • isBlocked: whether the Buddy is blocked in the User Buddy List
  • isTemp: a temporary Buddy is not stored in the Buddy List, it will be removed at the end of the session (see below)
  • variables: the Buddy variables which can be transient or persistent (see below)

Online State

Any user can decide if they want to be online/off-line as Buddy in the Buddy system. By default a User is online every time he joins the Zone, but the User can also turn off this flag at runtime and disappear from other User's buddy lists. The Online State is persistent and based on a reserved Buddy Variable.

Blocked Buddies

Buddies that are blocked won't be able to send any messages to the User, also they won't be able to see if the Buddy is online/off-line.

Buddy State message

The state message represents a typical IM Buddy state such as Available, Busy etc... By default the system already provides 3 default states: Available, Away, Occupied which can be changed or enriched at any time The state message is based on a reserved Buddy Variable.

Temp Buddy

A temporary Buddy is added to the User List when another User adds me to his Buddy List. This way we can see each others and exchange messages. If I don't add the User as Buddy in my list the User will remain temporary and it won't be persisted.

Variables

Buddy Variables enable each Buddy to show/send updates for specific informations to each User that has the Buddy in the list. For example one could send real-time updates on his last activity (ala Twitter) or post the title of the song he's listening right now, scores, rankings and whatnot.

Member Function Documentation

◆ ContainsVariable()

bool Sfs2X::Entities::SFSBuddy::ContainsVariable ( string  varName)
virtual

Return true if a BuddyVariable with the provided name exists

Parameters
varNameA string
Returns
A boolean

Implements Sfs2X::Entities::Buddy.

◆ GetOfflineVariables()

boost::shared_ptr< vector< boost::shared_ptr< BuddyVariable > > > Sfs2X::Entities::SFSBuddy::GetOfflineVariables ( )
virtual

Return a list of offline Buddy Variables

Returns
A vector of BuddyVariable pointers

Implements Sfs2X::Entities::Buddy.

◆ GetOnlineVariables()

boost::shared_ptr< vector< boost::shared_ptr< BuddyVariable > > > Sfs2X::Entities::SFSBuddy::GetOnlineVariables ( )
virtual

Return a list of non-persistent Buddy Variables

Returns
A vector of BuddyVariable pointers

Implements Sfs2X::Entities::Buddy.

◆ GetVariable()

boost::shared_ptr< BuddyVariable > Sfs2X::Entities::SFSBuddy::GetVariable ( string  varName)
virtual

Get the BuddyVariable with the provided name.

Null is returned if not BuddyVariable exists with that name

Parameters
varNameA string
Returns
Pointer to a BuddyVariable instance

Implements Sfs2X::Entities::Buddy.

◆ Id() [1/2]

long int Sfs2X::Entities::SFSBuddy::Id ( )
virtual

The id of the Buddy

The id corresponds to the current id of the User in the system

Implements Sfs2X::Entities::Buddy.

◆ Id() [2/2]

void Sfs2X::Entities::SFSBuddy::Id ( long int  value)
virtual

The id of the Buddy

The id corresponds to the current id of the User in the system

Implements Sfs2X::Entities::Buddy.

◆ IsBlocked() [1/2]

bool Sfs2X::Entities::SFSBuddy::IsBlocked ( )
virtual

Return true if the Buddy is blocked in the current Users' BuddyList

See also
Requests.BlockBuddyRequest

Implements Sfs2X::Entities::Buddy.

◆ IsBlocked() [2/2]

void Sfs2X::Entities::SFSBuddy::IsBlocked ( bool  value)
virtual

Return true if the Buddy is blocked in the current Users' BuddyList

See also
Requests.BlockBuddyRequest

Implements Sfs2X::Entities::Buddy.

◆ IsOnline()

bool Sfs2X::Entities::SFSBuddy::IsOnline ( )
virtual

Return true if the User is online in the BuddyList system

The value is stored in a reserved Buddy Variable

See also
Requests.GoOnlineRequest, ReservedBuddyVariables

Implements Sfs2X::Entities::Buddy.

◆ IsTemp()

bool Sfs2X::Entities::SFSBuddy::IsTemp ( )
virtual

Return true if the Buddy is temporary (not persistent)

Implements Sfs2X::Entities::Buddy.

◆ Name()

boost::shared_ptr< string > Sfs2X::Entities::SFSBuddy::Name ( )
virtual

The name of the Buddy

Implements Sfs2X::Entities::Buddy.

◆ NickName()

boost::shared_ptr< string > Sfs2X::Entities::SFSBuddy::NickName ( )
virtual

An optional Buddy nickname

The value is stored in a reserved Buddy Variable

See also
ReservedBuddyVariables

Implements Sfs2X::Entities::Buddy.

◆ State()

boost::shared_ptr< string > Sfs2X::Entities::SFSBuddy::State ( )
virtual

The current Buddy custom state (e.g. "Available", "Busy", etc...)

The value is stored in a reserved Buddy Variable

See also
ReservedBuddyVariables

Implements Sfs2X::Entities::Buddy.

◆ Variables()

boost::shared_ptr< vector< boost::shared_ptr< BuddyVariable > > > Sfs2X::Entities::SFSBuddy::Variables ( )
virtual

Obtain a list of BuddyVariables.

Please note that by convention any variable whose name starts with the dollar sign ($) will be regarded as persistent and stored locally by the server.

These variables are also referred to as "offline variables" because they are available to other Users even when the Buddy is offline.

See also
SFSBuddyVariable, Requests.SetBuddyVariablesRequest

Implements Sfs2X::Entities::Buddy.