Otclient
14/8/2020
|
#include <connection.h>
Public Member Functions | |
Connection () | |
~Connection () | |
void | connect (const std::string &host, uint16 port, const std::function< void()> &connectCallback) |
void | close () |
void | write (uint8 *buffer, size_t size) |
void | read (uint16 bytes, const RecvCallback &callback) |
void | read_until (const std::string &what, const RecvCallback &callback) |
void | read_some (const RecvCallback &callback) |
void | setErrorCallback (const ErrorCallback &errorCallback) |
int | getIp () |
boost::system::error_code | getError () |
bool | isConnecting () |
bool | isConnected () |
ticks_t | getElapsedTicksSinceLastRead () |
ConnectionPtr | asConnection () |
Public Member Functions inherited from LuaObject | |
LuaObject () | |
virtual | ~LuaObject () |
template<typename T > | |
void | connectLuaField (const std::string &field, const std::function< T > &f, bool pushFront=false) |
template<typename... T> | |
int | luaCallLuaField (const std::string &field, const T &... args) |
template<typename R , typename... T> | |
R | callLuaField (const std::string &field, const T &... args) |
template<typename... T> | |
void | callLuaField (const std::string &field, const T &... args) |
bool | hasLuaField (const std::string &field) |
Returns true if the lua field exists. More... | |
template<typename T > | |
void | setLuaField (const std::string &key, const T &value) |
Sets a field in this lua object. More... | |
template<typename T > | |
T | getLuaField (const std::string &key) |
Gets a field from this lua object. More... | |
void | releaseLuaFieldsTable () |
Release fields table reference. More... | |
void | luaSetField (const std::string &key) |
Sets a field from this lua object, the value must be on the stack. More... | |
void | luaGetField (const std::string &key) |
Gets a field from this lua object, the result is pushed onto the stack. More... | |
void | luaGetMetatable () |
Get object's metatable. More... | |
void | luaGetFieldsTable () |
Gets the table containing all stored fields of this lua object, the result is pushed onto the stack. More... | |
int | getUseCount () |
std::string | getClassName () |
Returns the derived class name, its the same name used in Lua. More... | |
LuaObjectPtr | asLuaObject () |
void | operator= (const LuaObject &) |
Public Member Functions inherited from stdext::shared_object | |
shared_object () | |
virtual | ~shared_object () |
void | add_ref () |
void | dec_ref () |
refcount_t | ref_count () |
template<typename T > | |
stdext::shared_object_ptr< T > | static_self_cast () |
template<typename T > | |
stdext::shared_object_ptr< T > | dynamic_self_cast () |
template<typename T > | |
stdext::shared_object_ptr< T > | const_self_cast () |
Static Public Member Functions | |
static void | poll () |
static void | terminate () |
Protected Member Functions | |
void | internal_connect (asio::ip::basic_resolver< asio::ip::tcp >::iterator endpointIterator) |
void | internal_write () |
void | onResolve (const boost::system::error_code &error, asio::ip::tcp::resolver::iterator endpointIterator) |
void | onConnect (const boost::system::error_code &error) |
void | onCanWrite (const boost::system::error_code &error) |
void | onWrite (const boost::system::error_code &error, size_t writeSize, std::shared_ptr< asio::streambuf > outputStream) |
void | onRecv (const boost::system::error_code &error, size_t recvSize) |
void | onTimeout (const boost::system::error_code &error) |
void | handleError (const boost::system::error_code &error) |
Protected Attributes | |
std::function< void()> | m_connectCallback |
ErrorCallback | m_errorCallback |
RecvCallback | m_recvCallback |
asio::deadline_timer | m_readTimer |
asio::deadline_timer | m_writeTimer |
asio::deadline_timer | m_delayedWriteTimer |
asio::ip::tcp::resolver | m_resolver |
asio::ip::tcp::socket | m_socket |
std::shared_ptr< asio::streambuf > | m_outputStream |
asio::streambuf | m_inputStream |
bool | m_connected |
bool | m_connecting |
boost::system::error_code | m_error |
stdext::timer | m_activityTimer |
Static Protected Attributes | |
static std::list< std::shared_ptr< asio::streambuf > > | m_outputStreams |
Friends | |
class | Server |
Definition at line 31 of file connection.h.
Connection::Connection | ( | ) |
Definition at line 34 of file connection.cpp.
Connection::~Connection | ( | ) |
|
inline |
void Connection::close | ( | ) |
Definition at line 66 of file connection.cpp.
void Connection::connect | ( | const std::string & | host, |
uint16 | port, | ||
const std::function< void()> & | connectCallback | ||
) |
Definition at line 93 of file connection.cpp.
|
inline |
Definition at line 64 of file connection.h.
|
inline |
Definition at line 61 of file connection.h.
int Connection::getIp | ( | ) |
Definition at line 309 of file connection.cpp.
|
protected |
Definition at line 297 of file connection.cpp.
|
protected |
Definition at line 108 of file connection.cpp.
|
protected |
Definition at line 140 of file connection.cpp.
|
inline |
|
inline |
|
protected |
Definition at line 241 of file connection.cpp.
|
protected |
Definition at line 218 of file connection.cpp.
|
protected |
Definition at line 267 of file connection.cpp.
|
protected |
Definition at line 205 of file connection.cpp.
|
protected |
Definition at line 289 of file connection.cpp.
|
protected |
Definition at line 252 of file connection.cpp.
|
static |
void Connection::read | ( | uint16 | bytes, |
const RecvCallback & | callback | ||
) |
Definition at line 157 of file connection.cpp.
void Connection::read_some | ( | const RecvCallback & | callback | ) |
void Connection::read_until | ( | const std::string & | what, |
const RecvCallback & | callback | ||
) |
Definition at line 173 of file connection.cpp.
|
inline |
|
static |
void Connection::write | ( | uint8 * | buffer, |
size_t | size | ||
) |
Definition at line 117 of file connection.cpp.
|
friend |
Definition at line 97 of file connection.h.
|
protected |
Definition at line 95 of file connection.h.
|
protected |
Definition at line 79 of file connection.h.
|
protected |
Definition at line 92 of file connection.h.
|
protected |
Definition at line 93 of file connection.h.
|
protected |
Definition at line 85 of file connection.h.
|
protected |
Definition at line 94 of file connection.h.
|
protected |
Definition at line 80 of file connection.h.
|
protected |
Definition at line 91 of file connection.h.
|
protected |
Definition at line 90 of file connection.h.
|
staticprotected |
Definition at line 89 of file connection.h.
|
protected |
Definition at line 83 of file connection.h.
|
protected |
Definition at line 81 of file connection.h.
|
protected |
Definition at line 86 of file connection.h.
|
protected |
Definition at line 87 of file connection.h.
|
protected |
Definition at line 84 of file connection.h.