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

Add a new Buddy to the current Buddy List More...

#include <AddBuddyRequest.h>

Inherits Sfs2X::Requests::BaseRequest.

Public Member Functions

 AddBuddyRequest (string buddyName)
 Constructor More...
 

Detailed Description

Add a new Buddy to the current Buddy List

Constructor & Destructor Documentation

◆ AddBuddyRequest()

Sfs2X::Requests::Buddylist::AddBuddyRequest::AddBuddyRequest ( string  buddyName)

Constructor

Parameters
buddyNamethe name of the buddy to add
ptrSmartFox->AddEventListener(SFSBuddyEvent::BUDDY_ADD, boost::shared_ptr<EventListenerDelegate> (EventListenerDelegate(CMyClass::OnBuddyAdded, (unsigned long long)this));
ptrSmartFox->AddEventListener(SFSBuddyEvent::BUDDY_ERROR, boost::shared_ptr<EventListenerDelegate> (EventListenerDelegate(CMyClass::OnBuddyError, (unsigned long long)this));
// Add a new buddy in the buddy list
boost::shared_ptr<IRequest> request (new AddBuddyRequest("Swedish Cook"));
ptrSmartFox->Send(request);
static void OnBuddyAdded(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
static void OnBuddyError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnBuddyAdded(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
{
CMyClass* ptrMyClass = (CMyClass*)ptrContext;
// Buddy was added
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));
}
void CMyClass::OnBuddyError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
{
CMyClass* ptrMyClass = (CMyClass*)ptrContext;
// Room password change failed
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueErrorMessage = (*ptrEventParams)["errorMessage"];
boost::shared_ptr<string> ptrErrorMessage = ((boost::static_pointer_cast<string>)(ptrEventParamValueErrorMessage));
}
See also
Core.SFSBuddyEvent.BUDDY_ADD, Core.SFSBuddyEvent.BUDDY_ERROR, RemoveBuddyRequest