Superclass for all TcpReceiver that communicate via a SOCKET and deliver their receive result, a type derived from AbstractMessage, to their "owner".
Since a message can be composed (it is a stream, which may be delivered in chunks), a buffer is created here, which contains data as long as the stream is not complete.
More...
#include <TcpDataReceiver.h>
Superclass for all TcpReceiver that communicate via a SOCKET and deliver their receive result, a type derived from AbstractMessage, to their "owner".
Since a message can be composed (it is a stream, which may be delivered in chunks), a buffer is created here, which contains data as long as the stream is not complete.
- Copyright
- © 2010 Helmut Jakoby
- Author
- Helmut Jakoby
◆ DataReceiver() [1/5]
tcp::DataReceiver::DataReceiver |
( |
| ) |
|
|
protected |
This constructor is not available.
◆ DataReceiver() [2/5]
tcp::DataReceiver::DataReceiver |
( |
SOCKET | | ) |
|
|
protected |
This constructor is not available.
◆ DataReceiver() [3/5]
tcp::DataReceiver::DataReceiver |
( |
TcpMain * | , |
|
|
SOCKET | ) |
|
protected |
This constructor is not available.
◆ DataReceiver() [4/5]
tcp::DataReceiver::DataReceiver |
( |
TcpMain * | pParent, |
|
|
SOCKET | Socket, |
|
|
unsigned int | uiDataSize ) |
Constructor with parameter passing.
- Parameters
-
[in] | pParent | The owning parent object. |
[in] | Socket | The socket through which communication takes place. |
[in] | uiDataSize | The package size. |
- Exceptions
-
◆ ~DataReceiver()
virtual tcp::DataReceiver::~DataReceiver |
( |
| ) |
|
|
virtual |
Destructor. It cleans up the individual buffers.
◆ DataReceiver() [5/5]
The copy constructor is not available.
◆ acceptMessage()
◆ generateNewTcpMessage() [1/2]
virtual void tcp::DataReceiver::generateNewTcpMessage |
( |
AbstractMessage *& | prTcpAbstractMessage, |
|
|
char * | pszRawMsg, |
|
|
unsigned int | uiRawMsgSize, |
|
|
unsigned int | uiMessageID, |
|
|
int | iActionCode, |
|
|
const std::string & | rstrInfo ) const |
|
protectedpure virtual |
Generates in subclasses a message derived from AbstractMessage from passed parameters.
- Parameters
-
[in,out] | prTcpAbstractMessage | Pointer to newly generated Message. This object takes over the removal of the pszRawMsg from the memory. |
[in] | pszRawMsg | The message data. |
[in] | uiRawMsgSize | The size or length of the message data. |
[in] | uiMessageID | A unique ID. |
[in] | iActionCode | The ActionCode. |
[in] | rstrInfo | An additional text info |
- Attention
- The supplied object must be removed from memory by the calling instance.
- See also
- AbstractMessage, Message, ServerAcceptMessage, ServerMessage
Implemented in tcp::ClientReceiver, and tcp::ServerReceiver.
◆ generateNewTcpMessage() [2/2]
virtual void tcp::DataReceiver::generateNewTcpMessage |
( |
AbstractMessage *& | prTcpAbstractMessage, |
|
|
char * | pszTransmitData, |
|
|
unsigned int | uiTransmitDataSize ) const |
|
protectedpure virtual |
Generates in subclasses a message derived from AbstractMessage from the passed data buffer and its size.
- Parameters
-
[in,out] | prTcpAbstractMessage | Pointer to newly generated Message. This object takes care of removing the pszTransmitData from the memory. |
[in] | pszTransmitData | The data buffer including all required information. |
[in] | uiTransmitDataSize | The size or length of the data buffer to be sent. |
- Attention
- The supplied object must be removed from memory by the calling instance.
- See also
- AbstractMessage, Message, ServerAcceptMessage, ServerMessage
Implemented in tcp::ClientReceiver, and tcp::ServerReceiver.
◆ getDataSize()
unsigned int tcp::DataReceiver::getDataSize |
( |
| ) |
const |
Returns the packet size.
- Returns
- , see above.
◆ initStreamData()
void tcp::DataReceiver::initStreamData |
( |
| ) |
|
|
protected |
Initializes the stream data (sets everything to zero).
◆ operator=()
The assignment operator is not available.
◆ processReceivedData()
int tcp::DataReceiver::processReceivedData |
( |
char * | pszSentBuffer, |
|
|
unsigned int | t_uiSentBufferSize ) |
|
protected |
Processes the received data and constructs a message from it (derived from AbstractMessage by calling the method generateNewTcpMessage (...) ) and passes it on to its owner via acceptMessage (...) .
- Parameters
-
[in] | pszSentBuffer | The received buffer |
[in] | t_uiSentBufferSize | The size of the buffer received |
- Returns
- A return < 0 indicates an error.
◆ setDataSize()
void tcp::DataReceiver::setDataSize |
( |
unsigned int | uiDataSize | ) |
|
Sets the packet size.
- Parameters
-
[in] | uiDataSize | The package size. |
◆ m_pszSentBuffer
char* tcp::DataReceiver::m_pszSentBuffer |
|
protected |
The received buffer in one receive step. Is transferred to the m_szStreamBuffer. If the size of the expected data packet is not yet reached, the next received buffer is appended to m_szStreamBuffer.
◆ m_szStreamBuffer
char* tcp::DataReceiver::m_szStreamBuffer |
|
protected |
◆ m_uiDataSize
unsigned int tcp::DataReceiver::m_uiDataSize |
|
protected |
◆ m_uiStreamPosistion
unsigned int tcp::DataReceiver::m_uiStreamPosistion |
|
protected |
The current stream position.
◆ m_uiStreamSize
unsigned int tcp::DataReceiver::m_uiStreamSize |
|
protected |
The stream size (from the header).
The documentation for this class was generated from the following file: