Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::server::AuthSystem Class Reference

System to handle player login operations on the server side. More...

#include <AuthSystem.hpp>

Inheritance diagram for rtp::server::AuthSystem:
Collaboration diagram for rtp::server::AuthSystem:

Public Member Functions

 AuthSystem (ServerNetwork &network, ecs::Registry &registry)
 Constructor for AuthSystem.
 
void update (float dt) override
 Update system logic for one frame.
 
std::tuple< bool, std::string, uint8_t > handleLoginRequest (uint32_t sessionId, const net::Packet &packet)
 Handle a login request from a client.
 
std::pair< bool, std::string > handleRegisterRequest (uint32_t sessionId, const net::Packet &packet)
 Handle a registration request from a client.
 
void sendLoginResponse (uint32_t sessionId, bool success, const std::string &username)
 Send a login response to a client.
 
void sendRegisterResponse (uint32_t sessionId, bool success, const std::string &username)
 Send a registration response to a client.
 
- Public Member Functions inherited from rtp::ecs::ISystem
virtual ~ISystem () noexcept=default
 

Private Attributes

ServerNetwork_network
 Reference to the server network manager.
 
ecs::Registry_registry
 Reference to the entity registry.
 

Detailed Description

System to handle player login operations on the server side.

Definition at line 30 of file AuthSystem.hpp.

Constructor & Destructor Documentation

◆ AuthSystem()

rtp::server::AuthSystem::AuthSystem ( ServerNetwork network,
ecs::Registry registry 
)

Constructor for AuthSystem.

Parameters
networkReference to the server network manager
registryReference to the entity registry

Definition at line 17 of file AuthSystem.cpp.

Member Function Documentation

◆ handleLoginRequest()

std::tuple< bool, std::string, uint8_t > rtp::server::AuthSystem::handleLoginRequest ( uint32_t  sessionId,
const net::Packet packet 
)

Handle a login request from a client.

Parameters
sessionIdID of the network session
packetPacket containing the login request data
Returns
tuple<success, username, weaponKind>

Definition at line 25 of file AuthSystem.cpp.

References rtp::log::error(), rtp::log::info(), rtp::net::LoginPayload::password, sendLoginResponse(), rtp::net::LoginPayload::username, rtp::log::warning(), and rtp::net::LoginPayload::weaponKind.

◆ handleRegisterRequest()

std::pair< bool, std::string > rtp::server::AuthSystem::handleRegisterRequest ( uint32_t  sessionId,
const net::Packet packet 
)

Handle a registration request from a client.

Parameters
sessionIdID of the network session
packetPacket containing the registration request data

Definition at line 63 of file AuthSystem.cpp.

References rtp::log::error(), rtp::log::info(), rtp::net::RegisterPayload::password, sendRegisterResponse(), rtp::net::RegisterPayload::username, and rtp::log::warning().

◆ sendLoginResponse()

void rtp::server::AuthSystem::sendLoginResponse ( uint32_t  sessionId,
bool  success,
const std::string &  username 
)

Send a login response to a client.

Parameters
sessionIdID of the network session
successWhether the login was successful
usernameThe username of the player

Definition at line 111 of file AuthSystem.cpp.

References _network, rtp::net::LoginResponse, rtp::server::ServerNetwork::sendPacket(), rtp::net::LoginResponsePayload::success, and rtp::net::TCP.

Referenced by handleLoginRequest().

◆ sendRegisterResponse()

void rtp::server::AuthSystem::sendRegisterResponse ( uint32_t  sessionId,
bool  success,
const std::string &  username 
)

Send a registration response to a client.

Parameters
sessionIdID of the network session
successWhether the registration was successful
usernameThe username of the player

Definition at line 122 of file AuthSystem.cpp.

References _network, rtp::net::RegisterResponse, rtp::server::ServerNetwork::sendPacket(), rtp::net::RegisterResponsePayload::success, and rtp::net::TCP.

Referenced by handleRegisterRequest().

◆ update()

void rtp::server::AuthSystem::update ( float  dt)
overridevirtual

Update system logic for one frame.

Parameters
dtTime elapsed since last update in seconds
Note
Currently not used

Implements rtp::ecs::ISystem.

Definition at line 20 of file AuthSystem.cpp.

Member Data Documentation

◆ _network

ServerNetwork& rtp::server::AuthSystem::_network
private

Reference to the server network manager.

Definition at line 78 of file AuthSystem.hpp.

Referenced by sendLoginResponse(), and sendRegisterResponse().

◆ _registry

ecs::Registry& rtp::server::AuthSystem::_registry
private

Reference to the entity registry.

Definition at line 79 of file AuthSystem.hpp.


The documentation for this class was generated from the following files: