Horizon Official Technical Documentation
|
|
#include <ZoneSession.hpp>
Public Member Functions | |
ZoneSession (uint64_t uid) | |
~ZoneSession () | |
void | transmit_buffer (ByteBuffer _buffer, std::size_t size) |
Queues a buffer to be sent to the client. More... | |
void | update (uint32_t diff) |
Update loop for each Zone Session. More... | |
void | perform_cleanup () |
Performs generic logout of player in cases where the connection was closed abruptly or by instruction. More... | |
void | initialize () |
Initializes the zone session's members. More... | |
std::unique_ptr< ZoneClientInterface > & | clif () |
std::unique_ptr< ClientPacketLengthTable > & | pkt_tbl () |
std::shared_ptr< Units::Player > | player () |
void | set_player (std::shared_ptr< Units::Player > pl) |
std::string | get_map_name () |
void | set_map_name (std::string map_name) |
![]() | |
Session (uint64_t uid) | |
virtual | ~Session () |
std::shared_ptr< ZoneSocket > | get_socket () |
Get the socket. More... | |
void | set_socket (std::weak_ptr< ZoneSocket > 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... | |
Protected Attributes | |
std::unique_ptr< ZoneClientInterface > | _clif |
std::unique_ptr< ClientPacketLengthTable > | _pkt_tbl |
std::shared_ptr< Units::Player > | _player |
std::string | _map_name {""} |
ZoneSession is responsible for handling the session of a client.
ZoneSession::ZoneSession | ( | uint64_t | uid | ) |
This is the constructor of the class ZoneSession.
uid | is a int64_t variable which is used to handle the unique id of the session. |
socket | is a shared pointer of type ZoneSocket which is used to handle the socket. |
ZoneSession::~ZoneSession | ( | ) |
|
inline |
This function is a getter function which is used to get the client interface.
References _clif.
|
inline |
|
virtual |
Initializes the zone session's members.
This function is used to handle the initialization of the session.
@thread Initialized from the Network Thread after socket and session creation.
Implements Horizon::Networking::Session< ZoneSocket, ZoneSession >.
References _clif, _pkt_tbl, HLog, and Horizon::Networking::Session< ZoneSocket, ZoneSession >::set_initialized().
void ZoneSession::perform_cleanup | ( | ) |
Performs generic logout of player in cases where the connection was closed abruptly or by instruction.
This function is used to handle the cleanup of the session.
Also marks the player for removal from the MapContainerThread. @thread Called from the NetworkThread.
|
inline |
|
inline |
This function is a getter function which is used to get the player.
References _player.
|
inline |
|
inline |
void ZoneSession::transmit_buffer | ( | ByteBuffer | _buffer, |
std::size_t | size | ||
) |
Queues a buffer to be sent to the client.
This function is used to queue the buffer to be sent to the client.
_buffer | is a reference to a ByteBuffer which is used to handle the buffer. |
size | is a size_t variable which is used to handle the size of the buffer. |
None |
_buffer | The buffer to be sent. |
size | The size of the buffer. |
References _pkt_tbl, ByteBuffer::active_length(), ByteBuffer::get_read_pointer(), Horizon::Networking::Session< ZoneSocket, ZoneSession >::get_socket(), HLog, and ByteBuffer::is_empty().
|
virtual |
Update loop for each Zone Session.
This function is used to handle the incoming packets from the client and categorize the packets to be processed by the server.
diff | is a uint32_t variable which is used to handle the time difference. |
@thread called from Runtime.
Implements Horizon::Networking::Session< ZoneSocket, ZoneSession >.
References _pkt_tbl, Horizon::Networking::Session< ZoneSocket, ZoneSession >::get_recv_queue(), Horizon::Networking::Session< ZoneSocket, ZoneSession >::get_socket(), and HLog.
|
protected |
Referenced by clif(), and initialize().
|
protected |
Referenced by get_map_name(), and set_map_name().
|
protected |
Referenced by initialize(), pkt_tbl(), transmit_buffer(), and update().
|
protected |
Referenced by player(), and set_player().