Package nbxmpp :: Module bosh :: Class NonBlockingBOSH |
[hide private]
[frames] | no frames]

# Class NonBlockingBOSH

source code

Instance Methods | [hide private]
__init__(self, raise_event, on_disconnect, idlequeue, estabilish_tls, certs, xmpp_server, domain, bosh_dict, proxy_creds) Each trasport class can have different constructor but it has to have at least all the arguments of NonBlockingTransport constructor | source code
connect(self, conn_5tuple, on_connect, on_connect_failure) Creates and connects transport to server and port defined in conn_5tuple which should be item from list returned from getaddrinfo | source code
_on_connect(self) Preceeds call of on_connect callback | source code
set_timeout(self, timeout) | source code
on_http_request_possible(self) Called when HTTP request it's possible to send a HTTP request. It can be when socket is connected or when HTTP response arrived | source code
get_socket_in(self, state) Get sockets in desired state | source code
get_free_socket(self) Select and returns socket eligible for sending a data to | source code
send_BOSH(self, payload) Tries to send a stanza in payload by appeding it to a buffer and plugging a free socket for writing. | source code
plug_socket(self) | source code
build_stanza(self, socket) Build a BOSH body tag from data in buffers and adds key, rid and ack attributes to it | source code
on_bosh_wait_timeout(self) | source code
renew_bosh_wait_timeout(self, timeout) | source code
remove_bosh_wait_timeout(self) | source code
on_persistent_fallback(self, socket) Called from underlying transport when server closes TCP connection | source code
handle_body_attrs(self, stanza_attrs) Called for each incoming body stanza from dispatcher. Checks body attributes. | source code
append_stanza(self, stanza) Append stanza to a buffer to send | source code
send(self, stanza, now=False) | source code
get_current_state(self) | source code
connect_and_flush(self, socket) | source code
boshify_stanzas(self, stanzas=`[``]`, body_attrs=None) Wraps zero to many stanzas by body tag with xmlns and sid | source code
send_init(self, after_SASL=False) | source code
start_disconnect(self) | source code
get_new_http_socket(self) | source code
onreceive(self, recv_handler) Set the on_receive callback. | source code
on_received_http(self, data, socket) | source code
disconnect(self, do_callback=True) | source code
Inherited from `transports_nb.NonBlockingTransport`: `get_fd`, `get_state`, `plugin`, `plugout`, `read_timeout`, `read_timeout2`, `remove_timeout`, `renew_send_timeout`, `renew_send_timeout2`, `set_send_timeout`, `set_send_timeout2`, `set_state`, `set_timeout2` Inherited from `transports_nb.NonBlockingTransport` (private): `_on_connect_failure`, `_tcp_connecting_started` Inherited from `plugin.PlugIn`: `PlugIn`, `PlugOut`

Class Methods | [hide private]
Inherited from `plugin.PlugIn`: `get_instance`

Method Details | [hide private]

### __init__(self, raise_event, on_disconnect, idlequeue, estabilish_tls, certs, xmpp_server, domain, bosh_dict, proxy_creds) (Constructor) | source code
Each trasport class can have different constructor but it has to have at least all the arguments of NonBlockingTransport constructor Parameters: `raise_event` - callback for monitoring of sent and received data `on_disconnect` - callback called on disconnection during runtime `idlequeue` - processing idlequeue `estabilish_tls` - boolean whether to estabilish TLS connection after TCP connection is done `certs` - tuple of (cacerts, mycerts) see constructor of tls_nb.NonBlockingTLS for more details Overrides: plugin.PlugIn.__init__

### connect(self, conn_5tuple, on_connect, on_connect_failure) | source code
Creates and connects transport to server and port defined in conn_5tuple which should be item from list returned from getaddrinfo Parameters: `conn_5tuple` - 5-tuple returned from getaddrinfo `on_connect` - callback called on successful connect to the server `on_connect_failure` - callback called on failure when connecting Overrides: transports_nb.NonBlockingTransport.connect (inherited documentation)

### _on_connect(self) | source code
Preceeds call of on_connect callback Overrides: transports_nb.NonBlockingTransport._on_connect (inherited documentation)

### set_timeout(self, timeout) | source code
Overrides: transports_nb.NonBlockingTransport.set_timeout

### on_http_request_possible(self) | source code
Called when HTTP request it's possible to send a HTTP request. It can be when socket is connected or when HTTP response arrived There should be always one pending request to BOSH CM.

### get_socket_in(self, state) | source code
Get sockets in desired state

### get_free_socket(self) | source code
Select and returns socket eligible for sending a data to

### send_BOSH(self, payload) | source code
Tries to send a stanza in payload by appeding it to a buffer and plugging a free socket for writing.

### plug_socket(self) | source code

### build_stanza(self, socket) | source code
Build a BOSH body tag from data in buffers and adds key, rid and ack attributes to it This method is called from _do_send() of underlying transport. This is to ensure rid and keys will be processed in correct order. If I generate them before plugging a socket for write (and did it for two sockets/HTTP connections) in parallel, they might be sent in wrong order, which results in violating the BOSH session and server-side disconnect.

### on_bosh_wait_timeout(self) | source code

### renew_bosh_wait_timeout(self, timeout) | source code

### remove_bosh_wait_timeout(self) | source code

### on_persistent_fallback(self, socket) | source code
Called from underlying transport when server closes TCP connection Parameters: `socket` - disconnected transport object

### handle_body_attrs(self, stanza_attrs) | source code
Called for each incoming body stanza from dispatcher. Checks body attributes.

### append_stanza(self, stanza) | source code
Append stanza to a buffer to send

### send(self, stanza, now=False) | source code
Overrides: transports_nb.NonBlockingTransport.send

### get_current_state(self) | source code

### connect_and_flush(self, socket) | source code

### boshify_stanzas(self, stanzas=`[``]`, body_attrs=None) | source code
Wraps zero to many stanzas by body tag with xmlns and sid

### send_init(self, after_SASL=False) | source code

### start_disconnect(self) | source code
Overrides: transports_nb.NonBlockingTransport.start_disconnect

### get_new_http_socket(self) | source code

### onreceive(self, recv_handler) | source code
Set the on_receive callback. onreceive(None) sets callback to Dispatcher.ProcessNonBlocking which is the default one that will decide what to do with received stanza based on its tag name and namespace. Do not confuse it with on_receive() method, which is the callback itself. Overrides: transports_nb.NonBlockingTransport.onreceive (inherited documentation)

### on_received_http(self, data, socket) | source code

### disconnect(self, do_callback=True) | source code
Overrides: transports_nb.NonBlockingTransport.disconnect