GlobalObjects
Loading...
Searching...
No Matches
tcp::ClientReceiver Class Reference

Class that communicates with a Server via a SOCKET and delivers its receive result of type Message to its "owner", which must be a Client. You can use the method ClientReceiver::acceptMessage(AbstractMessage * pTcpMessage) to change the delivery to the "owner" in subclasses by overwriting the method. More...

#include <TcpClientReceiver.h>

Inheritance diagram for tcp::ClientReceiver:

Public Member Functions

 ClientReceiver (Client *pParent, SOCKET Socket, unsigned int uiDataSize)
 
virtual ~ClientReceiver ()
 
virtual void cancel () override
 
bool connected () const
 
- Public Member Functions inherited from tcp::DataReceiver
 DataReceiver (TcpMain *pParent, SOCKET Socket, unsigned int uiDataSize)
 
virtual ~DataReceiver ()
 
unsigned int getDataSize () const
 
void setDataSize (unsigned int uiDataSize)
 
- Public Member Functions inherited from tcp::Receiver
 Receiver (TcpMain *pParent, SOCKET Socket)
 
virtual ~Receiver ()
 
- Public Member Functions inherited from tcp::ReceiverTransmitter
 ReceiverTransmitter (SOCKET Socket)
 
virtual ~ReceiverTransmitter ()
 
virtual void finishBreak () override
 
int getPeerName (std::string &rstrIPAdress, unsigned int &ruiPort) const
 
SOCKET Socket () const
 
virtual void takeABreak () override
 
- Public Member Functions inherited from eut::RepeatingThread
 RepeatingThread ()
 
virtual ~RepeatingThread ()
 
int getBreakCounter ()
 
bool isInExclusiveAccess () const
 
void setExclusiveAccess ()
 
void signalInput ()
 
virtual int start ()
 
RepeatingThread::STATUS status () const
 
bool testCancel ()
 
void unsetExclusiveAccess ()
 
void waitForInput ()
 

Protected Member Functions

 ClientReceiver ()
 
 ClientReceiver (SOCKET)
 
 ClientReceiver (TcpMain *, SOCKET)
 
 ClientReceiver (TcpMain *, SOCKET, unsigned int)
 
virtual int acceptMessage (AbstractMessage *pTcpMessage) override
 
virtual void generateNewTcpMessage (AbstractMessage *&prTcpMessage, char *pszRawMsg, unsigned int uiRawMsgSize, unsigned int uiMessageID, int iActionCode, const std::string &rstrInfo) const override
 
virtual void generateNewTcpMessage (AbstractMessage *&prTcpMessage, char *pszTransmitData, unsigned int uiTransmitDataSize) const override
 
virtual void work () override
 
- Protected Member Functions inherited from tcp::DataReceiver
 DataReceiver ()
 
 DataReceiver (SOCKET)
 
 DataReceiver (TcpMain *, SOCKET)
 
void initStreamData ()
 
int processReceivedData (char *pszSentBuffer, unsigned int t_uiSentBufferSize)
 
- Protected Member Functions inherited from tcp::Receiver
 Receiver ()
 
 Receiver (SOCKET Socket)
 
- Protected Member Functions inherited from tcp::ReceiverTransmitter
 ReceiverTransmitter ()
 
- Protected Member Functions inherited from eut::RepeatingThread
ORDER getOrder ()
 
STATUS getStatus ()
 
void setStatus (STATUS eStatus)
 
void threadWork ()
 
void toOrder (ORDER eOrder)
 

Private Member Functions

 ClientReceiver (const ClientReceiver &)
 
ClientReceiveroperator= (const ClientReceiver &)
 

Private Attributes

bool m_bHaveConnection
 

Additional Inherited Members

- Public Types inherited from eut::RepeatingThread
enum  EuTHREADERROR { EuTHREAD_ERR_NO_THREAD = -10301 , EuTHREAD_ERR_THREAD_ALREADY_WORKING = -10302 , EuTHREAD_ERR_THREAD_BREAK_COUNT_LESS_THAN_ZERO = -10303 , EuTHREAD_ERR_UNKNOWN = -10400 }
 Error range = -10301 to -10400 More...
 
enum  ORDER { eUNDEFINED , eDO_WORK , eEXIT }
 
enum  STATUS {
  eAT_THE_START , eWORKING , ePAUSING , eENDING ,
  eCOMPLETED
}
 
- Public Attributes inherited from eut::RepeatingThread
std::string m_strDebugInfo
 
- Protected Attributes inherited from tcp::DataReceiver
char * m_pszSentBuffer
 
char * m_szStreamBuffer
 
unsigned int m_uiDataSize
 
unsigned int m_uiStreamPosistion
 
unsigned int m_uiStreamSize
 
- Protected Attributes inherited from tcp::Receiver
TcpMainm_pParentTcpMain
 
- Protected Attributes inherited from tcp::ReceiverTransmitter
SOCKET m_Socket
 

Detailed Description

Class that communicates with a Server via a SOCKET and delivers its receive result of type Message to its "owner", which must be a Client. You can use the method ClientReceiver::acceptMessage(AbstractMessage * pTcpMessage) to change the delivery to the "owner" in subclasses by overwriting the method.

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ ClientReceiver() [1/6]

tcp::ClientReceiver::ClientReceiver ( )
protected

This constructor is not available.

◆ ClientReceiver() [2/6]

tcp::ClientReceiver::ClientReceiver ( SOCKET )
protected

This constructor is not available.

◆ ClientReceiver() [3/6]

tcp::ClientReceiver::ClientReceiver ( TcpMain * ,
SOCKET  )
protected

This constructor is not available.

◆ ClientReceiver() [4/6]

tcp::ClientReceiver::ClientReceiver ( TcpMain * ,
SOCKET ,
unsigned int  )
protected

This constructor is not available.

◆ ClientReceiver() [5/6]

tcp::ClientReceiver::ClientReceiver ( Client * pParent,
SOCKET Socket,
unsigned int uiDataSize )

Constructor with parameter passing.

Parameters
[in]pParentThe owning parent object.
[in]SocketThe socket through which communication takes place.
[in]uiDataSizeThe package size.
Exceptions
eut::ErrorNExceptionAn exception is thrown if an error occurs.

◆ ~ClientReceiver()

virtual tcp::ClientReceiver::~ClientReceiver ( )
virtual

Destructor.

◆ ClientReceiver() [6/6]

tcp::ClientReceiver::ClientReceiver ( const ClientReceiver & )
private

The copy constructor is not available.

Member Function Documentation

◆ acceptMessage()

virtual int tcp::ClientReceiver::acceptMessage ( AbstractMessage * pTcpMessage)
overrideprotectedvirtual

Forwards the transferred message to its Client, which also deletes the message after processing.
The Client can then process these further in subclasses if necessary. If processing in a subclass of ClientReceiver is required, this method can also be overwritten.

Parameters
[in]pTcpMessageThe received message.
Returns
A return < 0 indicates an error.
Attention
The passed object must not be removed from memory by the calling instance.
See also
Message

Implements tcp::DataReceiver.

◆ cancel()

virtual void tcp::ClientReceiver::cancel ( )
overridevirtual

Terminates the thread.

Reimplemented from eut::RepeatingThread.

◆ connected()

bool tcp::ClientReceiver::connected ( ) const

Is connected?

Returns
If true, the client Receiver has a SOCKET.

◆ generateNewTcpMessage() [1/2]

virtual void tcp::ClientReceiver::generateNewTcpMessage ( AbstractMessage *& prTcpMessage,
char * pszRawMsg,
unsigned int uiRawMsgSize,
unsigned int uiMessageID,
int iActionCode,
const std::string & rstrInfo ) const
overrideprotectedvirtual

Generates a Message from transferred parameters.

Parameters
[in,out]prTcpMessagePointer to newly generated Message. This object takes over the removal of the pszRawMsg from the memory.
[in]pszRawMsgThe message data.
[in]uiRawMsgSizeThe size or length of the message data.
[in]uiMessageIDA unique ID.
[in]iActionCodeThe ActionCode.
[in]rstrInfoAn additional text info
Attention
The supplied object must be removed from memory by the calling instance.
Exceptions
eut::ErrorNExceptionIf no Message can be instantiated from the parameters, an exception is thrown.
See also
Message

Implements tcp::DataReceiver.

◆ generateNewTcpMessage() [2/2]

virtual void tcp::ClientReceiver::generateNewTcpMessage ( AbstractMessage *& prTcpMessage,
char * pszTransmitData,
unsigned int uiTransmitDataSize ) const
overrideprotectedvirtual

Generates a Message from the transferred data buffer and its size.

Parameters
[in,out]prTcpMessagePointer to newly generated Message. This object takes care of removing the pszTransmitData from the memory.
[in]pszTransmitDataThe data buffer including all required information.
[in]uiTransmitDataSizeThe size or length of the data buffer to be sent.
Attention
The supplied object must be removed from memory by the calling instance.
Exceptions
eut::ErrorNExceptionIf no Message can be instantiated from the data (because, for example, the header is incorrect), an exception is thrown.
See also
Message

Implements tcp::DataReceiver.

◆ operator=()

ClientReceiver & tcp::ClientReceiver::operator= ( const ClientReceiver & )
private

The assignment operator is not available.

◆ work()

virtual void tcp::ClientReceiver::work ( )
overrideprotectedvirtual

Accepts streams from its socket (is blocked until received), turns the data into a Message which is further processed in ClientReceiver::acceptMessage(AbstractMessage * pTcpMessage).

Implements eut::RepeatingThread.

Member Data Documentation

◆ m_bHaveConnection

bool tcp::ClientReceiver::m_bHaveConnection
private

Auxiliary variable to indicate whether a connection is already established.


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