Horizon Official Technical Documentation
|
|
#include <CharSocket.hpp>
Public Member Functions | |
CharSocket (uint64_t uid, std::shared_ptr< tcp::socket > socket) | |
~CharSocket () | |
void | start () override |
Initial method invoked once from the network thread that handles the CharSocket. More... | |
bool | update () override |
Asynchronous update method periodically called from network threads. More... | |
std::shared_ptr< CharSession > | get_session () |
@thread created by network thread and called from main thread / client-sockt-mgr for update(). More... | |
void | set_session (std::shared_ptr< CharSession > session) |
void | update_session (uint32_t diff) |
![]() | |
Socket (uint64_t socket_id) | |
Socket (uint64_t socket_id, std::shared_ptr< tcp::socket > socket) | |
virtual | ~Socket () |
virtual void | start ()=0 |
Initial method invoked once from the network thread that handles the AuthSocket. More... | |
virtual bool | update () |
Socket update loop called from its NetworkThread every n nanoseconds. More... | |
uint64_t | get_socket_id () |
std::string & | remote_ip_address () |
uint16_t | remote_port () const |
void | async_read () |
Asynchronous read operation @thread NetworkThread. More... | |
void | async_read_with_callback (ByteBuffer &buf, void(Socket< CharSocket >::*)(boost::system::error_code, std::size_t)) |
Asynchronous read operation with callback handler @thread NetworkThread. More... | |
virtual void | queue_buffer (ByteBuffer &&buffer) |
bool | is_open () |
void | close_socket () |
Socket close operation that performs cleanups before shutting down the connection. More... | |
void | delayed_close_socket () |
ByteBuffer & | get_read_buffer () |
Protected Member Functions | |
void | read_handler () override |
Incoming buffer read handler. More... | |
void | on_close () override |
Socket cleanup method on connection closure. More... | |
void | on_error () override |
![]() | |
virtual void | on_close ()=0 |
virtual void | read_handler ()=0 |
virtual void | on_error ()=0 |
bool | async_process_queue () |
Socket write operation. More... | |
void | set_no_delay (bool enable) |
Disable the Nagle Algorithm on our socket. More... | |
std::size_t | write_buffer_and_send (ByteBuffer &to_send, boost::system::error_code &error) |
Write a message to the buffer. More... | |
Private Types | |
typedef Socket< CharSocket > | BaseSocket |
Private Attributes | |
std::shared_ptr< CharSession > | _session |
|
private |
|
explicit |
CharSocket::~CharSocket | ( | ) |
std::shared_ptr< CharSession > CharSocket::get_session | ( | ) |
@thread created by network thread and called from main thread / client-sockt-mgr for update().
References _session.
Referenced by read_handler(), and update_session().
|
overrideprotectedvirtual |
Socket cleanup method on connection closure.
Implements Horizon::Networking::Socket< CharSocket >.
References HLog, Horizon::Networking::Socket< CharSocket >::remote_ip_address(), and sClientSocketMgr.
|
overrideprotectedvirtual |
Implements Horizon::Networking::Socket< CharSocket >.
|
overrideprotectedvirtual |
Incoming buffer read handler.
Implements Horizon::Networking::Socket< CharSocket >.
References ByteBuffer::active_length(), ByteBuffer::append(), Horizon::Networking::Socket< CharSocket >::close_socket(), Horizon::Networking::Socket< CharSocket >::get_read_buffer(), get_session(), HLog, ByteBuffer::read_completed(), and ByteBuffer::to_string().
void CharSocket::set_session | ( | std::shared_ptr< CharSession > | session | ) |
|
overridevirtual |
Initial method invoked once from the network thread that handles the CharSocket.
Implements Horizon::Networking::Socket< CharSocket >.
References Horizon::Networking::Socket< CharSocket >::async_read(), Horizon::Networking::Socket< CharSocket >::get_socket_id(), HLog, Horizon::Networking::Socket< CharSocket >::remote_ip_address(), and set_session().
|
overridevirtual |
Asynchronous update method periodically called from network threads.
Reimplemented from Horizon::Networking::Socket< CharSocket >.
References get_shutdown_stage(), sClientSocketMgr, and SHUTDOWN_NOT_STARTED.
void CharSocket::update_session | ( | uint32_t | diff | ) |
|
private |
Referenced by get_session(), and set_session().