parent
cff3093cad
commit
ede802cc36
@ -0,0 +1,33 @@
|
||||
#ifndef MESSAGE_HPP
|
||||
#define MESSAGE_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
/** Append messageParts with buildMessage() to m_buffer.
|
||||
* Call onMessageReady() if the length of the buffer equals the value from
|
||||
* getExpectedLength().
|
||||
*/
|
||||
|
||||
class Message
|
||||
{
|
||||
public:
|
||||
|
||||
Message() : m_buffer() {};
|
||||
virtual ~Message() {};
|
||||
|
||||
virtual bool buildMessage( const unsigned char* messagePart,
|
||||
const int length ) = 0;
|
||||
virtual void onMessageReady() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual int getExpectedLength() = 0;
|
||||
|
||||
/// @todo shall i use dinamic array?
|
||||
std::string m_buffer;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // MESSAGE_HPP
|
@ -1,23 +0,0 @@
|
||||
#ifndef MESSAGE_BUILDER_HPP
|
||||
#define MESSAGE_BUILDER_HPP
|
||||
|
||||
class MessageBuilder
|
||||
{
|
||||
public:
|
||||
|
||||
bool buildMessage( const unsigned char* message, unsigned int length ) ;
|
||||
|
||||
protected:
|
||||
|
||||
MessageBuilder( const int bufferLength ) ;
|
||||
virtual ~MessageBuilder() ;
|
||||
virtual void onMessageReady( const unsigned char* message, unsigned int length ) = 0 ;
|
||||
|
||||
private:
|
||||
|
||||
unsigned char *m_buffer;
|
||||
int m_bufferLength;
|
||||
int m_bufferUsed;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_BUILDER_HPP
|
@ -1,32 +0,0 @@
|
||||
#ifndef MESSAGE_BUILDER_HPP
|
||||
#define MESSAGE_BUILDER_HPP
|
||||
|
||||
class TcpConnection;
|
||||
|
||||
|
||||
class MessageBuilder
|
||||
{
|
||||
public:
|
||||
|
||||
MessageBuilder( TcpConnection *connection,
|
||||
const int bufferLength = 1024 );
|
||||
|
||||
virtual ~MessageBuilder();
|
||||
|
||||
bool buildMessage( const unsigned char* message,
|
||||
const int length ) ;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
MessageBuilder(const MessageBuilder&);
|
||||
MessageBuilder& operator=(const MessageBuilder&);
|
||||
|
||||
|
||||
TcpConnection *m_connection;
|
||||
unsigned char *m_buffer;
|
||||
int m_bufferLength;
|
||||
int m_bufferUsed;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_BUILDER_HPP
|
Loading…
Reference in new issue