BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJSIP Reference

#include <presence.hpp>

Public Member Functions

 Buddy ()
 
virtual ~Buddy ()
 
void create (Account &acc, const BuddyConfig &cfg) PJSUA2_THROW(Error)
 
bool isValid () const
 
BuddyInfo getInfo () const PJSUA2_THROW(Error)
 
void subscribePresence (bool subscribe) PJSUA2_THROW(Error)
 
void updatePresence (void) PJSUA2_THROW(Error)
 
void sendInstantMessage (const SendInstantMessageParam &prm) PJSUA2_THROW(Error)
 
void sendTypingIndication (const SendTypingIndicationParam &prm) PJSUA2_THROW(Error)
 
virtual void onBuddyState ()
 
virtual void onBuddyEvSubState (OnBuddyEvSubStateParam &prm)
 

Friends

class Endpoint
 
class Account
 

Detailed Description

Buddy. This is a lite wrapper class for PJSUA-LIB buddy, i.e: this class only maintains one data member, PJSUA-LIB buddy ID, and the methods are simply proxies for PJSUA-LIB buddy operations.

Application can use create() to register a buddy to PJSUA-LIB, and the destructor of the original instance (i.e: the instance that calls create()) will unregister and delete the buddy from PJSUA-LIB. Application must delete all Buddy instances belong to an account before shutting down the account (via Account::shutdown()).

The library will not keep a list of Buddy instances, so any Buddy (or descendant) instances instantiated by application must be maintained and destroyed by the application itself. Any PJSUA2 APIs that return Buddy instance(s) such as Account::enumBuddies2() or Account::findBuddy2() will just return generated copy. All Buddy methods should work normally on this generated copy instance.

Constructor & Destructor Documentation

◆ Buddy()

pj::Buddy::Buddy ( )

Constructor.

◆ ~Buddy()

virtual pj::Buddy::~Buddy ( )
virtual

Destructor. Note that if the Buddy original instance (i.e: the instance that calls Buddy::create()) is destroyed, it will also delete the corresponding buddy in the PJSUA-LIB. While the destructor of a generated copy (i.e: Buddy instance returned by PJSUA2 APIs such as Account::enumBuddies2() or Account::findBuddy2()) will do nothing.

Member Function Documentation

◆ create()

void pj::Buddy::create ( Account acc,
const BuddyConfig cfg 
)

Create buddy and register the buddy to PJSUA-LIB.

Note that application should maintain the Buddy original instance, i.e: the instance that calls this create() method as it is only the original instance destructor that will delete the underlying Buddy in PJSUA-LIB.

Parameters
accThe account for this buddy.
cfgThe buddy config.

◆ isValid()

bool pj::Buddy::isValid ( ) const

Check if this buddy is valid.

Returns
True if it is.

◆ getInfo()

BuddyInfo pj::Buddy::getInfo ( ) const

Get detailed buddy info.

Returns
Buddy info.

Referenced by pj::FindBuddyMatch::match().

◆ subscribePresence()

void pj::Buddy::subscribePresence ( bool  subscribe)

Enable/disable buddy's presence monitoring. Once buddy's presence is subscribed, application will be informed about buddy's presence status changed via onBuddyState() callback.

Parameters
subscribeSpecify true to activate presence subscription.

◆ updatePresence()

void pj::Buddy::updatePresence ( void  )

Update the presence information for the buddy. Although the library periodically refreshes the presence subscription for all buddies, some application may want to refresh the buddy's presence subscription immediately, and in this case it can use this function to accomplish this.

Note that the buddy's presence subscription will only be initiated if presence monitoring is enabled for the buddy. See subscribePresence() for more info. Also if presence subscription for the buddy is already active, this function will not do anything.

Once the presence subscription is activated successfully for the buddy, application will be notified about the buddy's presence status in the onBuddyState() callback.

◆ sendInstantMessage()

void pj::Buddy::sendInstantMessage ( const SendInstantMessageParam prm)

Send instant messaging outside dialog, using this buddy's specified account for route set and authentication.

Parameters
prmSending instant message parameter.

◆ sendTypingIndication()

void pj::Buddy::sendTypingIndication ( const SendTypingIndicationParam prm)

Send typing indication outside dialog.

Parameters
prmSending instant message parameter.

◆ onBuddyState()

virtual void pj::Buddy::onBuddyState ( )
inlinevirtual

Notify application when the buddy state has changed. Application may then query the buddy info to get the details.

◆ onBuddyEvSubState()

virtual void pj::Buddy::onBuddyEvSubState ( OnBuddyEvSubStateParam prm)
inlinevirtual

Notify application when the state of client subscription session associated with a buddy has changed. Application may use this callback to retrieve more detailed information about the state changed event.

Parameters
prmCallback parameter.

References PJ_UNUSED_ARG.


The documentation for this class was generated from the following file:

 


PJSIP Open Source, high performance, small footprint, and very very portable SIP stack
Copyright (C) 2006-2008 Teluu Inc.