Changes between Initial Version and Version 1 of pjsip-doc/presence


Ignore:
Timestamp:
Dec 4, 2013 1:57:31 AM (11 years ago)
Author:
bennylp
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • pjsip-doc/presence

    v1 v1  
     1{{{ 
     2#!rst 
     3 
     4Buddy (Presence) 
     5================ 
     6This class represents a remote buddy (a person, or a SIP endpoint). 
     7To use the Buddy class, application DOES NOT need to subclass it unless application wants to get the notifications on buddy state change. 
     8 
     9Subscribe to Buddy's Presence Status 
     10--------------------------------------------------------- 
     11To subscribe to buddy's presence status, you need to add a buddy object, install callback to handle buddy's event, and start subscribing to buddy's presence status. The snippet below shows a sample code to achieve these:: 
     12 
     13  class MyBuddyCallback(pjsua.BuddyCallback): 
     14    def __init__(self, buddy=None): 
     15        pjsua.BuddyCallback.__init__(self, buddy) 
     16 
     17    def on_state(self): 
     18        print "Buddy", self.buddy.info().uri, "is", 
     19        print self.buddy.info().online_text 
     20 
     21  try: 
     22    uri = '"Alice" <sip:alice@example.com>' 
     23    buddy = acc.add_buddy(uri, cb=MyBuddyCallback()) 
     24    buddy.subscribe() 
     25 
     26  except pjsua.Error, err: 
     27    print 'Error adding buddy:', err 
     28 
     29For more information please see ​Buddy class and ​BuddyCallback class reference documentation. 
     30 
     31Responding to Presence Subscription Request 
     32 
     33By default, incoming presence subscription to an account will be accepted automatically. You will probably want to change this behavior, for example only to automatically accept subscription if it comes from one of the buddy in the buddy list, and for anything else prompt the user if he/she wants to accept the request. 
     34 
     35This can be done by implementing the ​on_incoming_subscribe() method of the ​AccountCallback class. 
     36 
     37Changing Account's Presence Status 
     38 
     39The ​Account class provides two methods to change account's presence status: 
     40 
     41​set_basic_status() can be used to set basic account's presence status (i.e. available or not available). 
     42​set_presence_status() can be used to set both the basic presence status and some extended information (e.g. busy, away, on the phone, etc.). 
     43When the presence status is changed, the account will publish the new status to all of its presence subscriber, either with PUBLISH request or SUBSCRIBE request, or both, depending on account configuration. 
     44 
     45}}}