SmartFoxServer 2X C++ API
Sfs2X::Requests::Buddylist::SetBuddyVariablesRequest Class Reference

Sets one or more BuddyVariables for the current User. This will update all Users in the Zona who have this User as Buddy in their Buddy Lists. More...

#include <SetBuddyVariablesRequest.h>

Inherits Sfs2X::Requests::BaseRequest.

Public Member Functions

 SetBuddyVariablesRequest (boost::shared_ptr< list< boost::shared_ptr< BuddyVariable > > > buddyVariables)
 Constructor More...
 

Detailed Description

Sets one or more BuddyVariables for the current User. This will update all Users in the Zona who have this User as Buddy in their Buddy Lists.

Constructor & Destructor Documentation

◆ SetBuddyVariablesRequest()

Sfs2X::Requests::Buddylist::SetBuddyVariablesRequest::SetBuddyVariablesRequest ( boost::shared_ptr< list< boost::shared_ptr< BuddyVariable > > >  buddyVariables)

Constructor

Parameters
buddyVariablesa list of BuddyVariables
// Add event listener for BuddyVariables
ptrSmartFox->AddEventListener(SFSEvent::BUDDY_VARIABLES_UPDATE, boost::shared_ptr<EventListenerDelegate> (EventListenerDelegate(CMyClass::OnBuddyVarsUpdate, (unsigned long long)this));
// This function could be invoked by a button click in the application GUI
// It updates a BuddyVariable with the title of the current track that the Users is listening to
boost::shared_ptr<list<boost::shared_ptr<BuddyVariable>>> myVars (new list<boost::shared_ptr<BuddyVariable>>());
boost::shared_ptr<std::string> value(new string("Beethoven's 8th Symphony"));
boost::shared_ptr<BuddyVariable> currentTrack (new SFSBuddyVariable("track", value, VARIABLETYPE_STRING));
myVars->push_back(currentTrack);
boost::shared_ptr<IRequest> request (new SetBuddyVariablesRequest(myVars));
ptrSmartFox->Send(request);
static void OnBuddyVarsUpdate(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
// This function will handle any Variables update from Buddies in our BuddyList
void CMyClass::OnBuddyVarsUpdate(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
{
CMyClass* ptrMyClass = (CMyClass*)ptrContext;
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueBuddy = (*ptrEventParams)["buddy"];
boost::shared_ptr<Buddy> ptrNotifiedBuddy = ((boost::static_pointer_cast<Buddy>)(ptrEventParamValueBuddy));
// Buddy was added
}
See also
Core.SFSBuddyEvent.BUDDY_VARIABLES_UPDATE, SFSBuddyVariable