String Handler class, an event handler who can handle network IO events for string message(ends with specific char)
More...
#include <StringHandler.h>
|
virtual int | OnRead (SessionPtr session, IoBufferPtr data) |
|
virtual int | OnWrite (SessionPtr session, IoBufferPtr data) |
|
virtual void | OnConnect (SessionPtr session) |
|
virtual void | OnDisconnect (SessionPtr session) |
|
virtual void | OnIdle (SessionPtr session, int idleType) |
|
virtual void | OnError (SessionPtr session, int errorType, int errorCode, const std::string &errorMsg) |
|
virtual void | HandleString (SessionPtr session, const std::string &str) |
|
|
static int | SplitStr (const std::string &src, const std::string &delims, std::vector< std::string > &strs) |
|
static std::string | TrimStr (std::string const &source, char const *spacechars=" \t\r\n") |
|
static std::string | GetDateTimeStr () |
|
static std::string | GetTimeStr () |
|
String Handler class, an event handler who can handle network IO events for string message(ends with specific char)
static std::string esnlib::StringHandler::GetDateTimeStr |
( |
| ) |
|
|
static |
Get current date and time in string format
- Returns
- Current date and time in string format
static std::string esnlib::StringHandler::GetTimeStr |
( |
| ) |
|
|
static |
Get current time in string format
- Returns
- Current time in string format
virtual void esnlib::StringHandler::HandleString |
( |
SessionPtr |
session, |
|
|
const std::string & |
str |
|
) |
| |
|
virtual |
Handle incoming string
- Parameters
-
session | Current session |
str | The incoming string |
virtual void esnlib::StringHandler::OnConnect |
( |
SessionPtr |
session | ) |
|
|
virtual |
The callback function for the OnConnect event
- Parameters
-
Implements esnlib::IoHandler.
virtual void esnlib::StringHandler::OnDisconnect |
( |
SessionPtr |
session | ) |
|
|
virtual |
The callback function for the OnDisconnect event
- Parameters
-
Implements esnlib::IoHandler.
virtual void esnlib::StringHandler::OnError |
( |
SessionPtr |
session, |
|
|
int |
errorType, |
|
|
int |
errorCode, |
|
|
const std::string & |
errorMsg |
|
) |
| |
|
virtual |
The callback function for the OnError 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::StringHandler::OnIdle |
( |
SessionPtr |
session, |
|
|
int |
idleType |
|
) |
| |
|
virtual |
The callback function for the OnIdle 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::StringHandler::OnRead |
( |
SessionPtr |
session, |
|
|
IoBufferPtr |
data |
|
) |
| |
|
virtual |
The callback function for the OnRead event
- Parameters
-
session | Current session |
data | The buffer pointer of the useful data read |
- Returns
- Whether need to take back the memory of the useful data
Implements esnlib::IoHandler.
virtual int esnlib::StringHandler::OnWrite |
( |
SessionPtr |
session, |
|
|
IoBufferPtr |
data |
|
) |
| |
|
virtual |
The callback function for the OnWrite event
- Parameters
-
session | Current session |
data | The buffer pointer of the data written |
- Returns
- Whether need to take back the memory of the data written
Implements esnlib::IoHandler.
static int esnlib::StringHandler::SplitStr |
( |
const std::string & |
src, |
|
|
const std::string & |
delims, |
|
|
std::vector< std::string > & |
strs |
|
) |
| |
|
static |
Split the string
- Parameters
-
src | The original string |
delims | The delimiters |
strs | The vector used to save the strings after splitting |
- Returns
- How many strings you will get after splitting
static std::string esnlib::StringHandler::TrimStr |
( |
std::string const & |
source, |
|
|
char const * |
spacechars = " \t\r\n" |
|
) |
| |
|
static |
Trim the string
- Parameters
-
source | The original string |
spacechars | The space characters |
- Returns
- The string after trimming
The documentation for this class was generated from the following file: