Package nbxmpp :: Module client_nb :: Class NonBlockingClient |
[hide private]
[frames] | no frames]

# Class NonBlockingClient

source code

Client class is XMPP connection mountpoint. Objects for authentication, network communication, roster, xml parsing ... are plugged to client object. Client implements the abstract behavior - mostly negotioation and callbacks handling, whereas underlying modules take care of feature-specific logic

Instance Methods | [hide private]
__init__(self, domain, idlequeue, caller=None) Caches connection data | source code
disconnect(self, message=`'````'`) Called on disconnection - disconnect callback is picked based on state of the client. | source code
connect(self, on_connect, on_connect_failure, hostname=None, port=5222, on_proxy_failure=None, on_stream_error_cb=None, proxy=None, secure_tuple=`(``'``plain``'``,` None`,` None`)`) Open XMPP connection (open XML streams in both directions) | source code
_resolve_hostname(self, hostname, port, on_success) Wrapper for getaddinfo call | source code
_try_next_ip(self, err_message=None) Iterate over IP addresses tries to connect to it | source code
incoming_stream_version(self) Get version of xml stream | source code
_xmpp_connect(self, socket_type=None) Start XMPP connecting process - open the XML stream. Is called after TCP connection is established or after switch to TLS when successfully negotiated with <starttls>. | source code
_xmpp_connect_machine(self, mode=None, data=None) Finite automaton taking care of stream opening and features tag handling. Calls _on_stream_start when stream is started, and disconnect() on failure. | source code
_on_stream_start(self) Called after XMPP stream is opened. TLS negotiation may follow if supported and desired. | source code
_tls_negotiation_handler(self, con=None, tag=None) Take care of TLS negotioation with <starttls> | source code
_on_connect(self) Preceed call of on_connect callback | source code
raise_event(self, event_type, data) Raise event to connection instance. DATA_SENT and DATA_RECIVED events are used in XML console to show XMPP traffic | source code
auth(self, user, password, resource=`'````'`, sasl=True, on_auth=None) Authenticate connnection and bind resource. If resource is not provided random one or library name used | source code
_on_old_auth(self, res) Callback used by NON-SASL auth. On auth failure, res is None | source code
_on_sasl_auth(self, res) Used internally. On auth failure, res is None | source code
_on_doc_attrs(self) Plug authentication objects and start auth | source code
_on_start_sasl(self, data=None) Callback used by SASL, called on each auth step | source code
_on_auth_bind(self, data) | source code
initRoster(self, version=`'````'`) Plug in the roster | source code
getRoster(self, on_ready=None, force=False) Return the Roster instance, previously plugging it in and requesting roster from server if needed | source code
sendPresence(self, jid=None, typ=None, requestRoster=0) Send some specific presence state. Can also request roster from server if according agrument is set | source code
RegisterDisconnectHandler(self, handler) Register handler that will be called on disconnect | source code
UnregisterDisconnectHandler(self, handler) Unregister handler that is called on disconnect | source code
DisconnectHandler(self) Default disconnect handler. Just raises an IOError. If you choosed to use this class in your production client, override this method or at least unregister it. | source code
get_connect_type(self) Return connection state. F.e.: None / 'tls' / 'plain+non_sasl' | source code
get_peerhost(self) Gets the ip address of the account, from which is made connection to the server (e.g. IP and port of socket) | source code

Method Details | [hide private]

### __init__(self, domain, idlequeue, caller=None) (Constructor) | source code
Caches connection data Parameters: `domain` - domain - for to: attribute (from account info) `idlequeue` - processing idlequeue `caller` - calling object - it has to implement methods _event_dispatcher which is called from dispatcher instance

### disconnect(self, message=`'````'`) | source code
Called on disconnection - disconnect callback is picked based on state of the client.

### connect(self, on_connect, on_connect_failure, hostname=None, port=5222, on_proxy_failure=None, on_stream_error_cb=None, proxy=None, secure_tuple=`(``'``plain``'``,` None`,` None`)`) | source code
Open XMPP connection (open XML streams in both directions) Parameters: `on_connect` - called after stream is successfully opened `on_connect_failure` - called when error occures during connection `hostname` - hostname of XMPP server from SRV request `port` - port number of XMPP server `on_proxy_failure` - called if error occurres during TCP connection to proxy server or during proxy connecting process `proxy` - dictionary with proxy data. It should contain at least values for keys 'host' and 'port' - connection details for proxy serve and optionally keys 'user' and 'pass' as proxy credentials `secure_tuple` - tuple of (desired connection type, cacerts, mycerts) connection type can be 'ssl' - TLS established after TCP connection, 'tls' - TLS established after negotiation with starttls, or 'plain'. cacerts, mycerts - see tls_nb.NonBlockingTLS constructor for more details

### _resolve_hostname(self, hostname, port, on_success) | source code
Wrapper for getaddinfo call FIXME: getaddinfo blocks

### _try_next_ip(self, err_message=None) | source code
Iterate over IP addresses tries to connect to it

### incoming_stream_version(self) | source code
Get version of xml stream

### _xmpp_connect(self, socket_type=None) | source code
Start XMPP connecting process - open the XML stream. Is called after TCP connection is established or after switch to TLS when successfully negotiated with <starttls>.

### _xmpp_connect_machine(self, mode=None, data=None) | source code
Finite automaton taking care of stream opening and features tag handling. Calls _on_stream_start when stream is started, and disconnect() on failure.

### _on_stream_start(self) | source code
Called after XMPP stream is opened. TLS negotiation may follow if supported and desired.

### _tls_negotiation_handler(self, con=None, tag=None) | source code
Take care of TLS negotioation with <starttls>

### _on_connect(self) | source code
Preceed call of on_connect callback

### raise_event(self, event_type, data) | source code
Raise event to connection instance. DATA_SENT and DATA_RECIVED events are used in XML console to show XMPP traffic

### auth(self, user, password, resource=`'````'`, sasl=True, on_auth=None) | source code
Authenticate connnection and bind resource. If resource is not provided random one or library name used Parameters: `user` - XMPP username `password` - XMPP password `resource` - resource that shall be used for auth/connecting `sasl` - Boolean indicating if SASL shall be used. (default: True) `on_auth` - Callback, called after auth. On auth failure, argument is None.

### _on_old_auth(self, res) | source code
Callback used by NON-SASL auth. On auth failure, res is None

### _on_sasl_auth(self, res) | source code
Used internally. On auth failure, res is None

### _on_doc_attrs(self) | source code
Plug authentication objects and start auth

### _on_start_sasl(self, data=None) | source code
Callback used by SASL, called on each auth step

### _on_auth_bind(self, data) | source code

### initRoster(self, version=`'````'`) | source code
Plug in the roster

### getRoster(self, on_ready=None, force=False) | source code
Return the Roster instance, previously plugging it in and requesting roster from server if needed

### sendPresence(self, jid=None, typ=None, requestRoster=0) | source code
Send some specific presence state. Can also request roster from server if according agrument is set

### RegisterDisconnectHandler(self, handler) | source code
Register handler that will be called on disconnect

### UnregisterDisconnectHandler(self, handler) | source code
Unregister handler that is called on disconnect

### DisconnectHandler(self) | source code
Default disconnect handler. Just raises an IOError. If you choosed to use this class in your production client, override this method or at least unregister it.

### get_connect_type(self) | source code
Return connection state. F.e.: None / 'tls' / 'plain+non_sasl'

### get_peerhost(self) | source code
Gets the ip address of the account, from which is made connection to the server (e.g. IP and port of socket) We will create listening socket on the same ip