Changes between Version 4 and Version 5 of Python_SIP/Accounts
- Timestamp:
- Jul 23, 2008 12:43:55 AM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Python_SIP/Accounts
v4 v5 7 7 Account 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. 8 8 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.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 [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. 10 10 11 11 Also 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. … … 18 18 So for example, we might identify ourself as ''"sip:192.168.0.15"'' (a user-less account) rather than ''"sip:user@pjsip.org"'' (an account). 19 19 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.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 [http://www.pjsip.org/python/pjsua.htm#Lib-create_transport lib.create_transport()] method as explained in previous chapter. 21 21 22 22 Here's a snippet: … … 57 57 Again the account callback will be explained later. 58 58 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.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. 60 60 61 61 Typically 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: … … 166 166 ''(Note: we omit error handling for brevity)'' 167 167 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: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: 169 169 170 170 {{{ … … 187 187 }}} 188 188 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. 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). 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. 190 192 191 193