Changes between Version 4 and Version 5 of Python_SIP/Accounts


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

--

Legend:

Unmodified
Added
Removed
Modified
  • Python_SIP/Accounts

    v4 v5  
    77Account may or may not have client registration associated with it. An account is also associated with route set and some authentication credentials, which are used when sending SIP request messages using the account. An account also has presence online status, which will be reported to remote peer when they subscribe to the account's presence, or which is published to a presence server if presence publication is enabled for the account. 
    88 
    9 At least one account MUST be created in the application, since any outgoing requests require an account context. If no user association is required, application can create a user-less account by calling {{{lib.create_account_for_transport()}}}. A userless account identifies local endpoint instead of a particular user, and it corresponds to a particular transport instance. 
     9At least one account MUST be created in the application, since any outgoing requests require an account context. If no user association is required, application can create a user-less account by calling [http://www.pjsip.org/python/pjsua.htm#Lib-create_account_for_transport lib.create_account_for_transport()]. A userless account identifies local endpoint instead of a particular user, and it corresponds to a particular transport instance. 
    1010 
    1111Also one account must be set as the default account, which will be used as the account identity when pjsua fails to match the request with any accounts using the stricter matching rules. 
     
    1818So for example, we might identify ourself as ''"sip:192.168.0.15"'' (a user-less account) rather than ''"sip:user@pjsip.org"'' (an account). 
    1919 
    20 In pjsua, a user-less account may be created for each particular transport instance. Creating user-less account is very simple, all we need is the transport instance which is returned by {{{lib.create_transport()}}} method as explained in previous chapter. 
     20In pjsua, a user-less account may be created for each particular transport instance. Creating user-less account is very simple, all we need is the transport instance which is returned by [http://www.pjsip.org/python/pjsua.htm#Lib-create_transport lib.create_transport()] method as explained in previous chapter. 
    2121 
    2222Here's a snippet: 
     
    5757Again the account callback will be explained later. 
    5858 
    59 The account created above doesn't do anything except to provide identity in the {{{From:}}} header for outgoing requests. The account will not register to SIP server or anything. 
     59The account created above doesn't do anything except to provide identity in the "{{{From:}}}" header for outgoing requests. The account will not register to SIP server or anything. 
    6060 
    6161Typically you will want the account to authenticate and register to your SIP server so that you can receive incoming calls. To do that you will need to configure some more settings in your [http://www.pjsip.org/python/pjsua.htm#AccountConfig AccountConfig], something like this: 
     
    166166''(Note: we omit error handling for brevity)'' 
    167167 
    168 That is the preferred way to install the callback, i.e. to specify the callback instance when creating the account. However, if for some reason you cannot do this, you may install the callback later using Account's [[http://www.pjsip.org/python/pjsua.htm#Account-set_callback set_callback()] method. You SHOULD, however, protect the code fragment with library lock to avoid loosing events. A sample code to do this: 
     168That is the preferred way to install the callback, i.e. to specify the callback instance when creating the account. However, if for some reason you cannot do this, you may install the callback later using Account's [http://www.pjsip.org/python/pjsua.htm#Account-set_callback set_callback()] method. You SHOULD, however, protect the code fragment with library lock to avoid loosing events. A sample code to do this: 
    169169 
    170170 {{{ 
     
    187187 }}} 
    188188 
    189 Without the library lock like above, it is possible that some events may be delivered to the account while the callback has not been installed yet, thus we're loosing the events. The lock will prevent that from happening (in this case), '''however''', please bear in mind that while you're holding the library lock, the worker thread can't run, so incoming SIP messages will be queued in socket buffer. So please use the library lock wisely. 
     189Without the library lock like above, it is possible that some events may be delivered to the account while the callback has not been installed yet, thus we're loosing the events. The lock will prevent that from happening (in this case). 
     190 
     191'''However''', please bear in mind that while you're holding the library lock, the worker thread can't run, so incoming SIP messages will be queued in socket buffer and some timers may be delayed. So please use the library lock wisely. 
    190192 
    191193