Package nbxmpp :: Module transports_nb :: Class NonBlockingTCP
[hide private]
[frames] | no frames]

Class NonBlockingTCP

source code


Non-blocking TCP socket wrapper

It is used for simple XMPP connection. Can be connected via proxy and can estabilish TLS connection.

Instance Methods [hide private]
 
__init__(self, raise_event, on_disconnect, idlequeue, estabilish_tls, certs, proxy_dict=None)
Each trasport class can have different constructor but it has to have at least all the arguments of NonBlockingTransport constructor
source code
 
start_disconnect(self) 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
 
_connect_to_proxy(self) source code
 
_on_connect(self)
Preceed invoking of on_connect callback. TCP connection is already estabilished by this time
source code
 
tls_init(self, on_succ, on_fail)
Estabilishes TLS/SSL using this TCP connection by plugging a NonBlockingTLS module
source code
 
pollin(self)
Called by idlequeu when receive on plugged socket is possible
source code
 
pollout(self)
Called by idlequeu when send to plugged socket is possible
source code
 
pollend(self)
Called by idlequeue on TCP connection errors
source code
 
disconnect(self, do_callback=True) source code
 
read_timeout(self)
Called when there's no response from server in defined timeout
source code
 
set_timeout(self, timeout) source code
 
remove_timeout(self) source code
 
send(self, raw_data, now=False)
Append raw_data to the queue of messages to be send. If supplied data is unicode string, encode it to utf-8.
source code
 
encode_stanza(self, stanza)
Encode str or unicode to utf-8
source code
 
_plug_idle(self, writable, readable)
Plug file descriptor of socket to Idlequeue
source code
 
_do_send(self)
Called when send() to connected socket is possible. First message from sendqueue will be sent
source code
 
_do_receive(self)
Reads all pending incoming data. Will call owner's disconnected() method if appropriate
source code
 
_on_receive(self, data)
Preceeds on_receive callback. It peels off and checks HTTP headers in HTTP classes, in here it just calls the callback
source code

Inherited from NonBlockingTransport: get_fd, get_state, onreceive, plugin, plugout, read_timeout2, renew_send_timeout, renew_send_timeout2, set_send_timeout, set_send_timeout2, set_state, set_timeout2

Inherited from plugin.PlugIn: PlugIn, PlugOut

Class Methods [hide private]

Inherited from plugin.PlugIn: get_instance

Instance Variables [hide private]

Inherited from idlequeue.IdleObject: fd

Method Details [hide private]

__init__(self, raise_event, on_disconnect, idlequeue, estabilish_tls, certs, proxy_dict=None)
(Constructor)

source code 
Each trasport class can have different constructor but it has to have at least all the arguments of NonBlockingTransport constructor
Parameters:
  • proxy_dict - dictionary with proxy data as loaded from config file
Overrides: idlequeue.IdleObject.__init__

start_disconnect(self)

source code 
Overrides: NonBlockingTransport.start_disconnect

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: NonBlockingTransport.connect
(inherited documentation)

_connect_to_proxy(self)

source code 

_on_connect(self)

source code 
Preceed invoking of on_connect callback. TCP connection is already estabilished by this time
Overrides: NonBlockingTransport._on_connect

tls_init(self, on_succ, on_fail)

source code 
Estabilishes TLS/SSL using this TCP connection by plugging a NonBlockingTLS module

pollin(self)

source code 
Called by idlequeu when receive on plugged socket is possible
Overrides: idlequeue.IdleObject.pollin

pollout(self)

source code 
Called by idlequeu when send to plugged socket is possible
Overrides: idlequeue.IdleObject.pollout

pollend(self)

source code 
Called by idlequeue on TCP connection errors
Overrides: idlequeue.IdleObject.pollend

disconnect(self, do_callback=True)

source code 
Overrides: NonBlockingTransport.disconnect

read_timeout(self)

source code 
Called when there's no response from server in defined timeout
Overrides: idlequeue.IdleObject.read_timeout
(inherited documentation)

set_timeout(self, timeout)

source code 
Overrides: NonBlockingTransport.set_timeout

remove_timeout(self)

source code 
Overrides: NonBlockingTransport.remove_timeout

send(self, raw_data, now=False)

source code 
Append raw_data to the queue of messages to be send. If supplied data is unicode string, encode it to utf-8.
Overrides: NonBlockingTransport.send

encode_stanza(self, stanza)

source code 
Encode str or unicode to utf-8

_plug_idle(self, writable, readable)

source code 

Plug file descriptor of socket to Idlequeue

Plugged socket will be watched for "send possible" or/and "recv possible" events. pollin() callback is invoked on "recv possible", pollout() on "send_possible".

Plugged socket will always be watched for "error" event - in that case, pollend() is called.

_do_send(self)

source code 
Called when send() to connected socket is possible. First message from sendqueue will be sent

_do_receive(self)

source code 
Reads all pending incoming data. Will call owner's disconnected() method if appropriate

_on_receive(self, data)

source code 
Preceeds on_receive callback. It peels off and checks HTTP headers in HTTP classes, in here it just calls the callback