Nebula
|
#include <tcpmessagecodec.h>
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.
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. | |
Private Types | |
enum | ReceiveState { HeaderData , MessageData } |
what data is currently expected from the decoder More... | |
Private Attributes | |
ReceiveState | receiveState |
Ptr< IO::Stream > | headerStream |
Ptr< IO::Stream > | messageStream |
SizeT | messageSize |
IndexT | headerPosition |
IndexT | messagePostition |
Util::Array< Ptr< IO::Stream > > | completedMessages |
|
private |
Net::TcpMessageCodec::TcpMessageCodec | ( | ) |
Constructor.
|
virtual |
Destructor.
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.
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.
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.
bool Net::TcpMessageCodec::HasMessages | ( | ) |
Returns true, if there are messages in the internal message queue.
Returns true if messages are available.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |