documentation for class Message added.

This commit is contained in:
Roland Jax
2014-11-11 20:57:07 +01:00
parent 773f5a6e30
commit 70ea02b143
3 changed files with 33 additions and 6 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ void BaseLoop::start()
// send result to client
result += '\n';
Connection* connection = static_cast<Connection*>(message->getSource());
Connection* connection = message->getConnection();
connection->addResult(Message(result));
delete message;
+1 -1
View File
@@ -77,7 +77,7 @@ void* Connection::run()
break;
// removed closed socket
if (datalen <= 0 || strncasecmp(data, "quit", 4) == 0)
if (datalen <= 0 || strcasecmp(data, "QUIT") == 0)
break;
// send data
+31 -4
View File
@@ -22,20 +22,47 @@
#include <string>
/** forward declaration for class Connection */
class Connection;
/**
* @brief class for data/message transfer between connection and baseloop
*/
class Message
{
public:
Message(const std::string data, void* source = NULL) : m_data(data), m_source(source) {}
Message(const Message& src) : m_data(src.m_data), m_source(src.m_source) {}
/**
* @brief constructs a new instance with message and source client address
* @param data from client
* @param connection to return result to correct client
*/
Message(const std::string data, Connection* connection=NULL)
: m_data(data), m_connection(connection) {}
/**
* @brief copy constructor.
* @param src message object for copy
*/
Message(const Message& src) : m_data(src.m_data), m_connection(src.m_connection) {}
/**
* @brief data from client
* @return data string
*/
std::string getData() const { return m_data; }
void* getSource() const { return m_source; }
/**
* @brief original connection
* @return pointer to connection
*/
Connection* getConnection() const { return m_connection; }
private:
/** the data/message string */
std::string m_data;
void* m_source;
/** the source connection */
Connection* m_connection;
};