BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJSIP Reference

PJSUA-API Buddy, Presence, and Instant Messaging

Buddy management, buddy's presence, and instant messaging. More...

Data Structures

struct  pjsua_buddy_config
 
struct  pjsua_buddy_info
 

Macros

#define PJSUA_MAX_BUDDIES   256
 
#define PJSUA_PRES_TIMER   300
 

Enumerations

enum  pjsua_buddy_status { PJSUA_BUDDY_STATUS_UNKNOWN, PJSUA_BUDDY_STATUS_ONLINE, PJSUA_BUDDY_STATUS_OFFLINE }
 

Functions

void pjsua_buddy_config_default (pjsua_buddy_config *cfg)
 
unsigned pjsua_get_buddy_count (void)
 
pj_bool_t pjsua_buddy_is_valid (pjsua_buddy_id buddy_id)
 
pj_status_t pjsua_enum_buddies (pjsua_buddy_id ids[], unsigned *count)
 
pjsua_buddy_id pjsua_buddy_find (const pj_str_t *uri)
 
pj_status_t pjsua_buddy_get_info (pjsua_buddy_id buddy_id, pjsua_buddy_info *info)
 
pj_status_t pjsua_buddy_set_user_data (pjsua_buddy_id buddy_id, void *user_data)
 
void * pjsua_buddy_get_user_data (pjsua_buddy_id buddy_id)
 
pj_status_t pjsua_buddy_add (const pjsua_buddy_config *buddy_cfg, pjsua_buddy_id *p_buddy_id)
 
pj_status_t pjsua_buddy_del (pjsua_buddy_id buddy_id)
 
pj_status_t pjsua_buddy_subscribe_pres (pjsua_buddy_id buddy_id, pj_bool_t subscribe)
 
pj_status_t pjsua_buddy_update_pres (pjsua_buddy_id buddy_id)
 
pj_status_t pjsua_pres_notify (pjsua_acc_id acc_id, pjsua_srv_pres *srv_pres, pjsip_evsub_state state, const pj_str_t *state_str, const pj_str_t *reason, pj_bool_t with_body, const pjsua_msg_data *msg_data)
 
void pjsua_pres_dump (pj_bool_t verbose)
 
pj_status_t pjsua_im_send (pjsua_acc_id acc_id, const pj_str_t *to, const pj_str_t *mime_type, const pj_str_t *content, const pjsua_msg_data *msg_data, void *user_data)
 
pj_status_t pjsua_im_typing (pjsua_acc_id acc_id, const pj_str_t *to, pj_bool_t is_typing, const pjsua_msg_data *msg_data)
 

Variables

const pjsip_method pjsip_message_method
 
const pjsip_method pjsip_info_method
 

Detailed Description

This section describes PJSUA-APIs related to buddies management, presence management, and instant messaging.

Macro Definition Documentation

#define PJSUA_MAX_BUDDIES   256

Max buddies in buddy list.

#define PJSUA_PRES_TIMER   300

This specifies how long the library should wait before retrying failed SUBSCRIBE request, and there is no rule to automatically resubscribe (for example, no "retry-after" parameter in Subscription-State header).

This also controls the duration before failed PUBLISH request will be retried.

Default: 300 seconds

Enumeration Type Documentation

This enumeration describes basic buddy's online status.

Enumerator
PJSUA_BUDDY_STATUS_UNKNOWN 

Online status is unknown (possibly because no presence subscription has been established).

PJSUA_BUDDY_STATUS_ONLINE 

Buddy is known to be online.

PJSUA_BUDDY_STATUS_OFFLINE 

Buddy is offline.

Function Documentation

void pjsua_buddy_config_default ( pjsua_buddy_config cfg)

Set default values to the buddy config.

unsigned pjsua_get_buddy_count ( void  )

Get total number of buddies.

Returns
Number of buddies.
pj_bool_t pjsua_buddy_is_valid ( pjsua_buddy_id  buddy_id)

Check if buddy ID is valid.

Parameters
buddy_idBuddy ID to check.
Returns
Non-zero if buddy ID is valid.
pj_status_t pjsua_enum_buddies ( pjsua_buddy_id  ids[],
unsigned *  count 
)

Enumerate all buddy IDs in the buddy list. Application then can use pjsua_buddy_get_info() to get the detail information for each buddy id.

Parameters
idsArray of ids to be initialized.
countOn input, specifies max elements in the array. On return, it contains actual number of elements that have been initialized.
Returns
PJ_SUCCESS on success, or the appropriate error code.
pjsua_buddy_id pjsua_buddy_find ( const pj_str_t uri)

Find the buddy ID with the specified URI.

Parameters
uriThe buddy URI.
Returns
The buddy ID, or PJSUA_INVALID_ID if not found.
pj_status_t pjsua_buddy_get_info ( pjsua_buddy_id  buddy_id,
pjsua_buddy_info info 
)

Get detailed buddy info.

Parameters
buddy_idThe buddy identification.
infoPointer to receive information about buddy.
Returns
PJ_SUCCESS on success, or the appropriate error code.
pj_status_t pjsua_buddy_set_user_data ( pjsua_buddy_id  buddy_id,
void *  user_data 
)

Set the user data associated with the buddy object.

Parameters
buddy_idThe buddy identification.
user_dataArbitrary application data to be associated with the buddy object.
Returns
PJ_SUCCESS on success, or the appropriate error code.
void* pjsua_buddy_get_user_data ( pjsua_buddy_id  buddy_id)

Get the user data associated with the budy object.

Parameters
buddy_idThe buddy identification.
Returns
The application data.
pj_status_t pjsua_buddy_add ( const pjsua_buddy_config buddy_cfg,
pjsua_buddy_id p_buddy_id 
)

Add new buddy to the buddy list. If presence subscription is enabled for this buddy, this function will also start the presence subscription session immediately.

Parameters
buddy_cfgBuddy configuration.
p_buddy_idPointer to receive buddy ID.
Returns
PJ_SUCCESS on success, or the appropriate error code.
pj_status_t pjsua_buddy_del ( pjsua_buddy_id  buddy_id)

Delete the specified buddy from the buddy list. Any presence subscription to this buddy will be terminated.

Parameters
buddy_idBuddy identification.
Returns
PJ_SUCCESS on success, or the appropriate error code.
pj_status_t pjsua_buddy_subscribe_pres ( pjsua_buddy_id  buddy_id,
pj_bool_t  subscribe 
)

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

Parameters
buddy_idBuddy identification.
subscribeSpecify non-zero to activate presence subscription to the specified buddy.
Returns
PJ_SUCCESS on success, or the appropriate error code.
pj_status_t pjsua_buddy_update_pres ( pjsua_buddy_id  buddy_id)

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 pjsua_buddy_subscribe_pres() 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 on_buddy_state() callback.

Parameters
buddy_idBuddy identification.
Returns
PJ_SUCCESS on success, or the appropriate error code.
pj_status_t pjsua_pres_notify ( pjsua_acc_id  acc_id,
pjsua_srv_pres srv_pres,
pjsip_evsub_state  state,
const pj_str_t state_str,
const pj_str_t reason,
pj_bool_t  with_body,
const pjsua_msg_data msg_data 
)

Send NOTIFY to inform account presence status or to terminate server side presence subscription. If application wants to reject the incoming request, it should set the state to PJSIP_EVSUB_STATE_TERMINATED.

Parameters
acc_idAccount ID.
srv_presServer presence subscription instance.
stateNew state to set.
state_strOptionally specify the state string name, if state is not "active", "pending", or "terminated".
reasonIf the new state is PJSIP_EVSUB_STATE_TERMINATED, optionally specify the termination reason.
with_bodyIf the new state is PJSIP_EVSUB_STATE_TERMINATED, this specifies whether the NOTIFY request should contain message body containing account's presence information.
msg_dataOptional list of headers to be sent with the NOTIFY request.
Returns
PJ_SUCCESS on success.
void pjsua_pres_dump ( pj_bool_t  verbose)

Dump presence subscriptions to log.

Parameters
verboseYes or no.
pj_status_t pjsua_im_send ( pjsua_acc_id  acc_id,
const pj_str_t to,
const pj_str_t mime_type,
const pj_str_t content,
const pjsua_msg_data msg_data,
void *  user_data 
)

Send instant messaging outside dialog, using the specified account for route set and authentication.

Parameters
acc_idAccount ID to be used to send the request.
toRemote URI.
mime_typeOptional MIME type. If NULL, then "text/plain" is assumed.
contentThe message content.
msg_dataOptional list of headers etc to be included in outgoing request. The body descriptor in the msg_data is ignored.
user_dataOptional user data, which will be given back when the IM callback is called.
Returns
PJ_SUCCESS on success, or the appropriate error code.
pj_status_t pjsua_im_typing ( pjsua_acc_id  acc_id,
const pj_str_t to,
pj_bool_t  is_typing,
const pjsua_msg_data msg_data 
)

Send typing indication outside dialog.

Parameters
acc_idAccount ID to be used to send the request.
toRemote URI.
is_typingIf non-zero, it tells remote person that local person is currently composing an IM.
msg_dataOptional list of headers etc to be added to outgoing request.
Returns
PJ_SUCCESS on success, or the appropriate error code.

Variable Documentation

const pjsip_method pjsip_message_method

The MESSAGE method (defined in pjsua_im.c)

const pjsip_method pjsip_info_method

The INFO method (defined in pjsua_call.c)

 


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