Version 1 (modified by bennylp, 16 years ago) (diff) |
---|
SIP Presence
TracNav
Subscribing to Buddy's Presence Status
To 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.
class MyBuddyCallback(pjsua.BuddyCallback): def __init__(self, buddy=None): pjsua.BuddyCallback.__init__(self, buddy) def on_state(self): print "Buddy", self.buddy.info().uri, "is", print self.buddy.info().online_text try: uri = '"Alice" <sip:alice@example.com>' buddy = acc.add_buddy(uri, cb=MyBuddyCallback()) buddy.subscribe() except pjsua.Error, err: print 'Error adding buddy:', err