Net::TcpMessageCodec Class Reference
#include <tcpmessagecodec.h>
Detailed Description
Helperclass that provides function to encode and decode sreams into messages.The encoder adds header informations at the beginning of the stream, that includes the complete size of the stream. Call EncodeToMessage at the sending site.
The decoder reads sequential incoming streams and append the data to an internal buffer. It concatenates the incoming streams to a list of streams containing complete messages. Call DecodeStream at the receiving site and check for completed messsages with GetMessages.
(C) 2009 Radon Labs
Public Member Functions | |
TcpMessageCodec () | |
Constructor. | |
virtual | ~TcpMessageCodec () |
Destructor. | |
void | EncodeToMessage (const Ptr< IO::Stream > &stream, const Ptr< IO::Stream > &output) |
Attachs header information to the stream and returns a copy with header. | |
void | DecodeStream (const Ptr< IO::Stream > &stream) |
Decodes a given Stream. Check for HasMessages() if this completes a message. | |
bool | HasMessages () |
Returns true, if there are messages in the internal message queue. | |
Util::Array< Ptr< IO::Stream > > | DequeueMessages () |
Gets the list of all created messages since the last call of this function. |
Member Function Documentation
void Net::TcpMessageCodec::EncodeToMessage | ( | const Ptr< IO::Stream > & | stream, | |
const Ptr< IO::Stream > & | output | |||
) |
Attachs header information to the stream and returns a copy with header.
Writes a copy of the given stream to the given output stream with header informations at the beginning.
void Net::TcpMessageCodec::DecodeStream | ( | const Ptr< IO::Stream > & | stream | ) |
Decodes a given Stream. Check for HasMessages() if this completes a message.
Puts a given stream to the internal buffer. This may result in new messages in the queue.
bool Net::TcpMessageCodec::HasMessages | ( | ) |
Returns true, if there are messages in the internal message queue.
Returns true if messages are available
Util::Array< Ptr< IO::Stream > > Net::TcpMessageCodec::DequeueMessages | ( | ) |
Gets the list of all created messages since the last call of this function.
Returns all created messages since the last call and clears message queue.