Line Protocol
This module implements the basic Line protocol.
This module can be used in both server and client implementations.
Append s to buffer and find any new lines of text in the string splitting at the standard IRC delimiter CRLF. Any new lines found, return them as a list and the remaining buffer for further processing.
Bases: circuits.core.events.Event
line Event
An event is a message send to one or more channels. It is eventually dispatched to all components that have handlers for one of the channels and the event type.
All normal arguments and keyword arguments passed to the constructor of an event are passed on to the handler. When declaring a handler, its argument list must therefore match the arguments used for creating the event.
Every event has a name attribute that is used for matching the event with the handlers.
Variables: |
|
---|
Bases: circuits.core.components.BaseComponent
Line Protocol
Implements the Line Protocol.
Incoming data is split into lines with a splitter function. For each line of data processed a Line Event is created. Any unfinished lines are appended into an internal buffer.
A custom line splitter function can be passed to customize how data is split into lines. This function must accept two arguments, the data to process and any left over data from a previous invocation of the splitter function. The function must also return a tuple of two items, a list of lines and any left over data.
Parameters: | splitter (function) – a line splitter function |
---|
This Component operates in two modes. In normal operation it’s expected to be used in conjunction with components that expose a Read Event on a “read” channel with only one argument (data). Some builtin components that expose such events are: - circuits.net.sockets.TCPClient - circuits.io.File
The second mode of operation works with circuits.net.sockets.Server components such as TCPServer, UNIXServer, etc. It’s expected that two arguments exist in the Read Event, sock and data. The following two arguments can be passed to affect how unfinished data is stored and retrieved for such components:
Parameters: | getBuffer (function) – function to retrieve the buffer for a client sock |
---|
This function must accept one argument (sock,) the client socket whoose buffer is to be retrieved.
Parameters: | updateBuffer (function) – function to update the buffer for a client sock |
---|
This function must accept two arguments (sock, buffer,) the client socket and the left over buffer to be updated.
initializes x; see x.__class__.__doc__ for signature