Package legume :: Package udp :: Module messages :: Class BaseMessage
[frames] | no frames]

type BaseMessage

object --+
         |
        BaseMessage
Known Subclasses:

Data packets must inherit from this base class. A subclass must have a static property called MessageTypeID set to a integer value to uniquely identify the packet within a single PacketFactory.
Instance Methods
 
__init__(self, *values)
 
getHeaderFormat(self)
Returns the header format as a struct compatible string.
 
getHeaderValues(self)
Returns a list containing the values used to construct the packet header.
 
getDataFormat(self)
Returns a struct compatible format string of the packet data
 
getMessageValues(self)
Returns a list containing the header+packet values used to construct the packet
 
getMessageFormat(self)
Returns a struct compatible format string of the message header and data
 
getPacketBytes(self)
Returns a string containing the header and data.
 
setMessageValuesToDefaults(self)
Override this method to assign default values.
 
readFromByteBuffer(self, byteBuffer)
Reconstitute the packet from a ByteBuffer instance
Static Methods
 
readHeaderFromByteBuffer(byteBuffer)
Read a packet header from an instance of ByteBuffer.
Class Variables
  HEADER_FORMAT = 'B'
  MessageTypeID = None
  MessageValues = None
  UseDefaultValues = True
Method Details

__init__(self, *values)
(Constructor)

 
Overrides: object.__init__
(inherited documentation)

getPacketBytes(self)

 
Returns a string containing the header and data. This string can be passed to .loadFromString(...).

readHeaderFromByteBuffer(byteBuffer)
Static Method

 
Read a packet header from an instance of ByteBuffer. This method will return a tuple containing the header values.