pybitmessage.network.advanceddispatcher module

Improved version of asyncore dispatcher

exception ProcessingError[source]

Bases: exceptions.Exception

General class for protocol parser exception, use as a base for others.

exception UnknownStateError[source]

Bases: pybitmessage.network.advanceddispatcher.ProcessingError

Parser points to an unknown (unimplemented) state.

class AdvancedDispatcher(sock=None)[source]

Bases: network.asyncore_pollchoose.dispatcher

Improved version of asyncore dispatcher, with buffers and protocol state.

append_write_buf(data)

Append binary data to the end of stream write buffer.

slice_write_buf(length=0)

Cut the beginning of the stream write buffer.

slice_read_buf(length=0)

Cut the beginning of the stream read buffer.

process()

Process (parse) data that’s in the buffer, as long as there is enough data and the connection is open.

set_state(state_str, length=0, expectBytes=0)

Set the next processing state.

writable()

Is data from the write buffer ready to be sent to the network?

readable()

Is the read buffer ready to accept data from the network?

handle_read()

Append incoming data to the read buffer.

handle_write()

Send outgoing data from write buffer.

handle_connect_event()

Callback for connection established event.

handle_connect()

Method for handling connection established implementations.

state_close()

Signal to the processing loop to end.

handle_close()

Callback for connection being closed, but can also be called directly when you want connection to close.