You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.1 KiB
67 lines
1.1 KiB
9 years ago
|
#ifndef PRINT_MESSAGE_HPP
|
||
|
#define PRINT_MESSAGE_HPP
|
||
12 years ago
|
|
||
12 years ago
|
#include <cpp_utils/Message.hpp>
|
||
12 years ago
|
|
||
9 years ago
|
/// @brief prints the received message
|
||
|
class PrintMessage : public Message
|
||
12 years ago
|
{
|
||
|
public:
|
||
|
|
||
9 years ago
|
PrintMessage( void *msgParam = 0)
|
||
12 years ago
|
: Message(msgParam)
|
||
|
{
|
||
|
TRACE;
|
||
|
}
|
||
|
|
||
|
bool buildMessage( const void *msgPart,
|
||
|
const size_t msgLen )
|
||
|
{
|
||
|
TRACE;
|
||
|
m_buffer = std::string( (const char*) msgPart, msgLen );
|
||
9 years ago
|
|
||
|
// not using getExpectedLength
|
||
12 years ago
|
onMessageReady();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
void onMessageReady()
|
||
|
{
|
||
|
TRACE;
|
||
|
|
||
|
LOG_BEGIN(Logger::INFO)
|
||
|
LOG_PROP("message", m_buffer)
|
||
9 years ago
|
LOG_PROP("host", m_connection->getHost())
|
||
|
LOG_PROP("port", m_connection->getPort())
|
||
|
LOG_END("Got message.");
|
||
12 years ago
|
|
||
9 years ago
|
// threat m_params as "isready" flag
|
||
12 years ago
|
*( static_cast<bool*>(m_param) ) = true;
|
||
|
|
||
|
m_buffer.clear();
|
||
|
}
|
||
|
|
||
|
Message* clone()
|
||
|
{
|
||
|
TRACE;
|
||
9 years ago
|
return new PrintMessage(m_param);
|
||
12 years ago
|
}
|
||
|
|
||
|
std::string getBuffer()
|
||
|
{
|
||
|
TRACE;
|
||
|
return m_buffer;
|
||
|
}
|
||
|
|
||
|
protected:
|
||
|
|
||
|
size_t getExpectedLength()
|
||
|
{
|
||
|
TRACE;
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
9 years ago
|
#endif // PRINT_MESSAGE_HPP
|