documentation for class Message added.
This commit is contained in:
@@ -85,7 +85,7 @@ void BaseLoop::start()
|
|||||||
|
|
||||||
// send result to client
|
// send result to client
|
||||||
result += '\n';
|
result += '\n';
|
||||||
Connection* connection = static_cast<Connection*>(message->getSource());
|
Connection* connection = message->getConnection();
|
||||||
connection->addResult(Message(result));
|
connection->addResult(Message(result));
|
||||||
|
|
||||||
delete message;
|
delete message;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ void* Connection::run()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// removed closed socket
|
// removed closed socket
|
||||||
if (datalen <= 0 || strncasecmp(data, "quit", 4) == 0)
|
if (datalen <= 0 || strcasecmp(data, "QUIT") == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// send data
|
// send data
|
||||||
|
|||||||
+31
-4
@@ -22,20 +22,47 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
/** forward declaration for class Connection */
|
||||||
|
class Connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief class for data/message transfer between connection and baseloop
|
||||||
|
*/
|
||||||
class Message
|
class Message
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
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; }
|
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:
|
private:
|
||||||
|
/** the data/message string */
|
||||||
std::string m_data;
|
std::string m_data;
|
||||||
void* m_source;
|
/** the source connection */
|
||||||
|
Connection* m_connection;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user