network.serializers - Palamecia/mint GitHub Wiki
Description
This module provides classes implementing the network serializer interface. A network serializer class allows conversions between message objects and byte streams (represented by an instance of Serializer.DataStream).
A serializer class must follow this interface:
appendMessage
def appendMessage(self, message)
Appends the message object provided by message
to the serializer's buffer.
nextMessage
def nextMessage(self)
Returns the next message object in the serializer's buffer or none
if no
message object can be constructed from the data in the buffer. The data used to
create the message is then removed from the buffer.
containsMessage
def containsMessage(const self)
Returns true
if a message can be constructed from the data in the serializer's
buffer; otherwise returns false
.
read
def read(self, endpoint)
Performs a read operation on endpoint
and append received data to the
serializer's buffer. Returns true
if data was receive; otherwise returns
false
.
write
def write(self, endpoint)
Performs a write operation on endpoint
using the data available in the
serializer's buffer. Returns true
if the data was successfully sent; otherwise
returns false
. After this call, the sent data should be removed from the buffer.
accept
def accept(self, endpoint)
Performs an accept operation on endpoint
and push the new endpoint in the
serializer's buffer. Returns true
if a new connection was successfully accepted;
otherwise returns false
.