Package SpecClient :: Module SpecMessage :: Class SpecMessage
[hide private]
[frames] | no frames]

Class SpecMessage

source code

Known Subclasses:

Base class for messages.

Instance Methods [hide private]
 
__init__(self, packedHeader)
Constructor
source code
 
isComplete(self)
Return wether a message read from stream has been fully received or not.
source code
 
readFromStream(self, streamBuf)
Read buffer from stream and try to create a message from it
source code
 
readHeader(self, rawstring)
Read the header of the message coming from stream
source code
 
readData(self, rawstring, datatype)
Read the data part of the message coming from stream
source code
 
dataType(self, data)
Try to guess data type
source code
 
sendingDataString(self, data, datatype)
Return the string representing the data part of the message.
source code
 
sendingString(self)
Create a string representing the message which can be send over the socket.
source code
Method Details [hide private]

__init__(self, packedHeader)
(Constructor)

source code 

Constructor

Arguments: packedHeader -- string representing the packed header format for the message, use the same syntax as the 'struct' Python module

readFromStream(self, streamBuf)

source code 

Read buffer from stream and try to create a message from it

Arguments: streamBuf - string buffer of the last bytes received from Spec

Return value : the number of consumed bytes

readHeader(self, rawstring)

source code 

Read the header of the message coming from stream

Arguments: rawstring -- raw bytes of the header

Return value: (message data type, message data len) tuple

readData(self, rawstring, datatype)

source code 

Read the data part of the message coming from stream

Arguments: rawstring -- raw data bytes datatype -- data type

Return value: the data read

dataType(self, data)

source code 

Try to guess data type

Works for obvious cases only

  • it is a hard job guessing ARRAY_* types, we ignore this case (user has to provide a suitable datatype)
  • we cannot make a difference between ERROR type and STRING type