Changes between Version 2 and Version 3 of Python_SIP/Accounts


Ignore:
Timestamp:
Jul 23, 2008 12:22:46 AM (16 years ago)
Author:
bennylp
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Python_SIP/Accounts

    v2 v3  
    9797 
    9898 
     99== Account Operations == 
     100 
     101Some of the operations to the [http://www.pjsip.org/python/pjsua.htm#Account Account] object: 
     102 * make outgoing calls 
     103 * add buddy objects 
     104 * set account's presence status 
     105 * stop/start SIP registration 
     106 
     107Please see the reference documentation for Account (link above) for more info. Calls, presence, and buddy list will be explained in later chapters. 
     108 
     109 
     110== Account Callbacks == 
     111 
     112Account object emits events, such as: 
     113 * the status of SIP registration 
     114 * incoming calls 
     115 * incoming presence subscription requests 
     116 * incoming instant message not from buddy 
     117 
     118These events will be reported to [http://www.pjsip.org/python/pjsua.htm#AccountCallback AccountCallback] instance that is registered to the account object. Application MUST install a class derived from [http://www.pjsip.org/python/pjsua.htm#AccountCallback AccountCallback] class if it wants to handle these events.  
     119 
     120If these events are not handled, default actions will be invoked: 
     121 * incoming calls will be rejected  
     122 * incoming presence subscription requests will be accepted 
     123 * incoming instant messages from non-buddy will be ignored 
     124 
     125=== Creating Custom Callback Class === 
     126 
     127To create a custom callback class to handle the events, derive a class from [http://www.pjsip.org/python/pjsua.htm#AccountCallback AccountCallback] and override the relevant class method to handle the particular events. For example: 
     128 
     129 {{{ 
     130#!python 
     131 
     132class MyAccountCallback(pjsua.AccountCallback): 
     133    def __init__(self, account=None): 
     134        pjsua.AccountCallback.__init__(self, account) 
     135 
     136    def on_incoming_call(self, call): 
     137        call.hangup(501, "Sorry, not ready to accept calls yet") 
     138 
     139    def on_reg_state(self): 
     140        print "Registration complete, status=", self.account.info().reg_status, \ 
     141              "(" + self.account.info().reg_reason + ")" 
     142 }}} 
     143 
     144In the account callback, you can refer the [http://www.pjsip.org/python/pjsua.htm#Account Account] instance of this callback with '''self.account'''. 
     145 
     146 
    99147[[TracNav(Python_SIP/TOC)]]