Script transports_nb_py_orig :: Class NonBlockingTCP
[hide private]
[frames] | no frames]

Class NonBlockingTCP


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
 
start_disconnect(self)
 
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
 
_connect_to_proxy(self)
 
_on_connect(self)
Preceed invoking of on_connect callback. TCP connection is already estabilished by this time
 
tls_init(self, on_succ, on_fail)
Estabilishes TLS/SSL using this TCP connection by plugging a NonBlockingTLS module
 
pollin(self)
Called by idlequeu when receive on plugged socket is possible
 
pollout(self)
Called by idlequeu when send to plugged socket is possible
 
pollend(self)
Called by idlequeue on TCP connection errors
 
disconnect(self, do_callback=True)
 
read_timeout(self)
Called when there's no response from server in defined timeout
 
set_timeout(self, timeout)
 
remove_timeout(self)
 
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.
 
encode_stanza(self, stanza)
Encode str or unicode to utf-8
 
_plug_idle(self, writable, readable)
Plug file descriptor of socket to Idlequeue
 
_do_send(self)
Called when send() to connected socket is possible. First message from sendqueue will be sent
 
_do_receive(self)
Reads all pending incoming data. Will call owner's disconnected() method if appropriate
 
_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

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 nbxmpp.plugin.PlugIn: PlugIn, PlugOut

Class Methods [hide private]

Inherited from nbxmpp.plugin.PlugIn: get_instance

Instance Variables [hide private]

Inherited from nbxmpp.idlequeue.IdleObject: fd

Method Details [hide private]

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

 
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: nbxmpp.idlequeue.IdleObject.__init__

start_disconnect(self)

 
Overrides: NonBlockingTransport.start_disconnect

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
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)

 

_on_connect(self)

 
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)

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

pollin(self)

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

pollout(self)

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

pollend(self)

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

disconnect(self, do_callback=True)

 
Overrides: NonBlockingTransport.disconnect

read_timeout(self)

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

set_timeout(self, timeout)

 
Overrides: NonBlockingTransport.set_timeout

remove_timeout(self)

 
Overrides: NonBlockingTransport.remove_timeout

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.
Overrides: NonBlockingTransport.send

encode_stanza(self, stanza)

 
Encode str or unicode to utf-8

_plug_idle(self, writable, readable)

 

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)

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

_do_receive(self)

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

_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