8#ifndef RTYPE_NETWORK_SESSION_HPP_
9 #define RTYPE_NETWORK_SESSION_HPP_
22 class Session :
public std::enable_shared_from_this<Session> {
32 asio::ip::tcp::socket socket,
33 asio::ip::udp::socket& serverUdpSocket,
64 void setId(uint32_t
id);
70 uint32_t
getId()
const;
95 asio::awaitable<void>
reader(
void);
101 asio::awaitable<void>
writer(
void);
Network packet implementation for R-Type protocol.
Interface for network event handling.
Network packet with header and serializable body.
asio::ip::udp::socket & _serverUdpSocket
Reference to the server's UDP socket.
asio::ip::tcp::endpoint getTcpEndpoint() const
Set the TCP endpoint for the session.
void setUdpEndpoint(const asio::ip::udp::endpoint &endpoint)
Set the UDP endpoint for the session.
uint32_t getId() const
Get the unique identifier for the session.
bool _stopped
Flag indicating if the session is stopped.
std::mutex _writeMutex
Mutex for synchronizing write operations.
asio::steady_timer _timer
Timer for managing write operations.
bool _hasUdp
Flag indicating if UDP endpoint is set.
asio::ip::tcp::socket _socket
TCP socket associated with the session.
void setId(uint32_t id)
Set the unique identifier for the session.
void send(const Packet &packet, NetworkMode mode)
Send a packet to the client.
void stop(void)
Stop the session's operations.
asio::ip::udp::endpoint getUdpEndpoint() const
Get the UDP endpoint for the session.
asio::awaitable< void > writer(void)
Asynchronous writer coroutine for the session.
std::deque< Packet > _writeQueue
Queue of packets to be written to the TCP socket.
uint32_t _id
Unique identifier for the session.
~Session()
Destructor for Session.
IEventPublisher & _publisher
Reference to the event publisher for network events.
asio::ip::udp::endpoint _udpEndpoint
UDP endpoint associated with the session.
void start(void)
Start the session's read and write operations.
asio::awaitable< void > reader(void)
Asynchronous reader coroutine for the session.
File : IEventPublisher.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue....
NetworkMode
Enum representing network transmission modes.