Horizon Official Technical Documentation
|
|
A Session object that handles a single socket. Sockets are moved into the thread by SocketMgr, once accepted or connected. Once started, the object blocks to handle I/O events and requires explicit stopping. More...
#include <Session.hpp>
Public Member Functions | |
Session (uint64_t uid) | |
virtual | ~Session () |
std::shared_ptr< SocketType > | get_socket () |
Get the socket. More... | |
void | set_socket (std::weak_ptr< SocketType > socket) |
Set the socket. More... | |
virtual void | update (uint32_t diff)=0 |
virtual void | initialize ()=0 |
bool | is_initialized () |
Called to verify if the session is initialized. More... | |
void | set_initialized (bool initialized) |
Set whether the session is initialized or not. More... | |
uint64_t | get_session_id () |
Get the unique id of the session. More... | |
ThreadSafeQueue< ByteBuffer > & | get_recv_queue () |
Receive queue of the buffer received by the socket. More... | |
Private Attributes | |
ThreadSafeQueue< ByteBuffer > | _buffer_recv_queue |
std::weak_ptr< SocketType > | _socket |
bool | _is_initialized { false } |
uint64_t | _uid { 0 } |
A Session object that handles a single socket. Sockets are moved into the thread by SocketMgr, once accepted or connected. Once started, the object blocks to handle I/O events and requires explicit stopping.
SocketType | The type of socket to use. |
SessionType | The type of session to use. |
uid | The unique id of the session. |
socket | The socket to use. |
is_initialized | Whether the session is initialized or not. |
_uid | The unique id of the session. |
_socket | The socket to use. |
|
inline |
|
inlinevirtual |
|
inline |
Receive queue of the buffer received by the socket.
References Horizon::Networking::Session< SocketType, SessionType >::_buffer_recv_queue.
|
inline |
Get the unique id of the session.
References Horizon::Networking::Session< SocketType, SessionType >::_uid.
|
inline |
Get the socket.
References Horizon::Networking::Session< SocketType, SessionType >::_socket.
|
pure virtual |
Called when the session is started. Virtual method that must be implmented by the derived class. Typically used to initialize the session.
Implemented in Horizon::Char::CharSession, Horizon::Zone::ZoneSession, and Horizon::Auth::AuthSession.
|
inline |
Called to verify if the session is initialized.
References Horizon::Networking::Session< SocketType, SessionType >::_is_initialized.
|
inline |
Set whether the session is initialized or not.
initialized | Whether the session is initialized or not. |
References Horizon::Networking::Session< SocketType, SessionType >::_is_initialized.
|
inline |
Set the socket.
socket | The socket. |
References Horizon::Networking::Session< SocketType, SessionType >::_socket.
|
pure virtual |
Called when the session is started. Virtual method that must be implmented by the derived class. Typically used to update the session and process packets.
Implemented in Horizon::Char::CharSession, Horizon::Zone::ZoneSession, and Horizon::Auth::AuthSession.
|
private |
|
private |
|
private |
|
private |