Changes between Initial Version and Version 1 of Python_SIP/Presence


Ignore:
Timestamp:
Jul 23, 2008 9:08:47 PM (16 years ago)
Author:
bennylp
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Python_SIP/Presence

    v1 v1  
     1= SIP Presence = 
     2 
     3[[TracNav(Python_SIP/TOC)]] 
     4 
     5 
     6== Subscribing to Buddy's Presence Status == 
     7 
     8To 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. 
     9 
     10 {{{ 
     11#!python 
     12 
     13class 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 
     21try: 
     22    uri = '"Alice" <sip:alice@example.com>' 
     23    buddy = acc.add_buddy(uri, cb=MyBuddyCallback()) 
     24    buddy.subscribe() 
     25 
     26except pjsua.Error, err: 
     27    print 'Error adding buddy:', err 
     28 }}} 
     29 
     30 
     31== Responding to Presence Subscription Request == 
     32 
     33