Nebula
Loading...
Searching...
No Matches
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.

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::StreamheaderStream
 
Ptr< IO::StreammessageStream
 
SizeT messageSize
 
IndexT headerPosition
 
IndexT messagePostition
 
Util::Array< Ptr< IO::Stream > > completedMessages
 

Member Enumeration Documentation

◆ ReceiveState

what data is currently expected from the decoder

Enumerator
HeaderData 
MessageData 

Constructor & Destructor Documentation

◆ TcpMessageCodec()

Net::TcpMessageCodec::TcpMessageCodec ( )

Constructor.

◆ ~TcpMessageCodec()

Net::TcpMessageCodec::~TcpMessageCodec ( )
virtual

Destructor.

Member Function Documentation

◆ DecodeStream()

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.

◆ DequeueMessages()

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.

◆ EncodeToMessage()

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.

◆ HasMessages()

bool Net::TcpMessageCodec::HasMessages ( )

Returns true, if there are messages in the internal message queue.

Returns true if messages are available.

Member Data Documentation

◆ completedMessages

Util::Array<Ptr<IO::Stream> > Net::TcpMessageCodec::completedMessages
private

◆ headerPosition

IndexT Net::TcpMessageCodec::headerPosition
private

◆ headerStream

Ptr<IO::Stream> Net::TcpMessageCodec::headerStream
private

◆ messagePostition

IndexT Net::TcpMessageCodec::messagePostition
private

◆ messageSize

SizeT Net::TcpMessageCodec::messageSize
private

◆ messageStream

Ptr<IO::Stream> Net::TcpMessageCodec::messageStream
private

◆ receiveState

ReceiveState Net::TcpMessageCodec::receiveState
private

The documentation for this class was generated from the following files: