A class that translates raw binary data to network messages and vice versa. More...
#include <message_translator.hpp>
Public Types | |
| typedef function< MessagePackageSharedPtr()> | CreationFunction |
| Creator function for network message types. More... | |
| typedef vector< char > | MtDataBuffer |
| Container type for raw data. More... | |
Public Member Functions | |
| MessagePackageSharedPtr | createMessage (const string &type) |
| Creates message of given type. More... | |
| void | getRaw (MtDataBuffer &data) |
| Translates outgoing message queue to raw data that can be serialized across network. More... | |
| MessageTranslator (MessagePackage::SerializationFormat format=MessagePackage::SerializationFormatBinary) | |
| Constructor. More... | |
| void | receive (int clientId, MessageArray &messages) |
| Translates received data in incoming data pool to messages. More... | |
| MessagePackage::SerializationFormat & | serializationFormat () |
| Returns the serialization type of an attached network adapter. More... | |
| void | setRaw (const MtDataBuffer &data) |
| Copies given data to incoming data pool that can be later on translated to network messages. More... | |
| bool | transmit (const MessagePackage &message) |
| Pushes given message to outgoing message queue that will be processed later on. More... | |
| ~MessageTranslator () | |
| Destructor. More... | |
Static Public Member Functions | |
| static bool | unwrap (shared_ptr< MessageContainer > serializer, const vector< char > &inBuffer, MessagePackage::SerializationFormat format, bool hasLength) |
| Deserializes array of messages (see MessageContainer) from an array of bytes. More... | |
| static void | wrap (const shared_ptr< MessageContainer > serializer, vector< char > &outBuffer, MessagePackage::SerializationFormat format) |
| Serializes array of messages (see MessageContainer) into array of bytes that has length of the payload encoded. More... | |
A class that translates raw binary data to network messages and vice versa.
| typedef function<MessagePackageSharedPtr()> kanzi::connect::MessageTranslator::CreationFunction |
Creator function for network message types.
| typedef vector<char> kanzi::connect::MessageTranslator::MtDataBuffer |
Container type for raw data.
| kanzi::connect::MessageTranslator::MessageTranslator | ( | MessagePackage::SerializationFormat | format = MessagePackage::SerializationFormatBinary | ) |
Constructor.
| kanzi::connect::MessageTranslator::~MessageTranslator | ( | ) |
Destructor.
| MessagePackageSharedPtr kanzi::connect::MessageTranslator::createMessage | ( | const string & | type | ) |
Creates message of given type.
| type | Type of the message. |
| void kanzi::connect::MessageTranslator::getRaw | ( | MtDataBuffer & | data | ) |
Translates outgoing message queue to raw data that can be serialized across network.
| data | Output raw data buffer. |
| void kanzi::connect::MessageTranslator::receive | ( | int | clientId, |
| MessageArray & | messages | ||
| ) |
Translates received data in incoming data pool to messages.
| clientId | Id of the client that sent the messages. |
| messages | Container for incoming messages. |
|
inline |
Returns the serialization type of an attached network adapter.
| void kanzi::connect::MessageTranslator::setRaw | ( | const MtDataBuffer & | data | ) |
Copies given data to incoming data pool that can be later on translated to network messages.
| data | Incoming raw data buffer. |
| bool kanzi::connect::MessageTranslator::transmit | ( | const MessagePackage & | message | ) |
Pushes given message to outgoing message queue that will be processed later on.
|
static |
Deserializes array of messages (see MessageContainer) from an array of bytes.
| serializer | Message container into which extract messages |
| inBuffer | Array containing serialized messages. |
| format | Serialization format. Either binary or JSON. |
| hasLength | Boolean indicating whether serialized buffer contains payload length. |
|
static |
Serializes array of messages (see MessageContainer) into array of bytes that has length of the payload encoded.
| serializer | Message container to be serialized |
| outBuffer | Array, into which serialized bytes are appended |
| format | Serialization format. Either binary or JSON. |