Common Message Handler class, an event handler who can handle network IO events for common message(format: header + body)
More...
#include <MessageHandler.h>
|
WorkManagerPtr | m_manager |
|
WorkPtr | m_work |
|
Common Message Handler class, an event handler who can handle network IO events for common message(format: header + body)
esnlib::MessageHandler::MessageHandler |
( |
WorkManagerPtr |
manager | ) |
|
|
explicit |
Constructor function
- Parameters
-
manager | The pointer of the work manager (a thread pool manager) |
esnlib::MessageHandler::MessageHandler |
( |
WorkManagerPtr |
manager, |
|
|
WorkPtr |
work |
|
) |
| |
Constructor function
- Parameters
-
manager | The pointer of the work manager (a thread pool manager) |
work | The pointer of the work (which provides the callback function for the threads) |
int esnlib::MessageHandler::DefaultAsyncProcessOnWrite |
( |
SessionPtr |
session, |
|
|
IoBufferPtr |
data |
|
) |
| |
|
protected |
The default callback function for the OnWrite event to process outgoing data asynchronously
- Parameters
-
session | Current session |
data | The buffer pointer of the data written |
- Returns
- The flags of the event processing: 1 = async, 2 = concurrent, 3 = both 1 and 2
virtual int esnlib::MessageHandler::GetCode |
( |
IoBuffer * |
data | ) |
|
|
virtual |
Get the code from the buffer data
- Parameters
-
- Returns
- The code
WorkPtr esnlib::MessageHandler::GetDefaultWork |
( |
| ) |
|
Get default work (the action that will be executed in threads)
- Returns
- The DefaultWork (pointer)
virtual int esnlib::MessageHandler::GetFlag |
( |
IoBuffer * |
data | ) |
|
|
virtual |
Get the flag from the buffer data
- Parameters
-
- Returns
- The flag
virtual int esnlib::MessageHandler::GetIntKey |
( |
IoBuffer * |
data | ) |
|
|
virtual |
Get the integer key from the buffer data
- Parameters
-
- Returns
- The integer key
virtual std::string esnlib::MessageHandler::GetStrKey |
( |
IoBuffer * |
data | ) |
|
|
virtual |
Get the string key from the buffer data
- Parameters
-
- Returns
- The string key
WorkManagerPtr esnlib::MessageHandler::GetWorkManager |
( |
| ) |
|
virtual void esnlib::MessageHandler::HandleMessage |
( |
SessionPtr |
session, |
|
|
IoBufferPtr |
data |
|
) |
| |
|
virtual |
Handle incoming data
- Parameters
-
session | Current session |
data | The incoming data |
virtual bool esnlib::MessageHandler::IsOrderlyMessage |
( |
IoBuffer * |
data | ) |
|
|
virtual |
Check whether the message is an orderly message
- Parameters
-
- Returns
- Return true if the message is orderly
virtual void esnlib::MessageHandler::OnConnect |
( |
SessionPtr |
session | ) |
|
|
virtual |
virtual void esnlib::MessageHandler::OnDisconnect |
( |
SessionPtr |
session | ) |
|
|
virtual |
The callback function for the Disconnect event
- Parameters
-
Implements esnlib::IoHandler.
virtual void esnlib::MessageHandler::OnError |
( |
SessionPtr |
session, |
|
|
int |
errorType, |
|
|
int |
errorCode, |
|
|
const std::string & |
errorMsg |
|
) |
| |
|
virtual |
The callback function for the Error event
- Parameters
-
session | Current session |
errorType | The error type (1 for read error, 2 for write error, 0 for connect error) |
errorCode | The error code (if error type == 0 and error code == 0, that means connect timeout) |
errorMsg | The error message |
Implements esnlib::IoHandler.
virtual void esnlib::MessageHandler::OnIdle |
( |
SessionPtr |
session, |
|
|
int |
idleType |
|
) |
| |
|
virtual |
The callback function for the Idle event
- Parameters
-
session | Current session |
idleType | The idle type (1 for read idle, 2 for write idle, 0 for both) |
Implements esnlib::IoHandler.
virtual int esnlib::MessageHandler::OnRead |
( |
SessionPtr |
session, |
|
|
IoBufferPtr |
data |
|
) |
| |
|
virtual |
The callback function for the Read event
- Parameters
-
session | Current session |
data | The buffer pointer of the useful data read |
- Returns
- The flags of the event processing: 1 = async, 2 = concurrent, 3 = both 1 and 2
Implements esnlib::IoHandler.
virtual int esnlib::MessageHandler::OnWrite |
( |
SessionPtr |
session, |
|
|
IoBufferPtr |
data |
|
) |
| |
|
virtual |
The callback function for the Write event
- Parameters
-
session | Current session |
data | The buffer pointer of the data written |
- Returns
- The flags of the event processing: 1 = async, 2 = concurrent, 3 = both 1 and 2
Implements esnlib::IoHandler.
The documentation for this class was generated from the following file: