R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
server::SessionManager Class Reference

Manages active player sessions with authentication support. More...

#include <SessionManager.hpp>

Inheritance diagram for server::SessionManager:
Inheritance graph
Collaboration diagram for server::SessionManager:
Collaboration graph

Public Member Functions

 SessionManager ()
 
 SessionManager (std::shared_ptr< AuthService > authService)
 
 ~SessionManager () override=default
 
std::shared_ptr< SessioncreateSession (const std::string &id) override
 Create a new session.
 
std::shared_ptr< SessiongetSession (const std::string &id) override
 Get session by ID.
 
void removeSession (const std::string &id) override
 Remove session by ID.
 
std::string authenticateAndCreateSession (const std::string &username, const std::string &password)
 Authenticate and create a session.
 
std::shared_ptr< AuthServicegetAuthService ()
 Get the auth service.
 
- Public Member Functions inherited from server::ISessionManager
virtual ~ISessionManager ()=default
 

Private Attributes

std::unordered_map< std::string, std::shared_ptr< Session > > _sessions
 
std::shared_ptr< AuthService_authService
 

Detailed Description

Manages active player sessions with authentication support.

Definition at line 21 of file SessionManager.hpp.

Constructor & Destructor Documentation

◆ SessionManager() [1/2]

server::SessionManager::SessionManager ( )

Definition at line 13 of file SessionManager.cpp.

◆ SessionManager() [2/2]

server::SessionManager::SessionManager ( std::shared_ptr< AuthService authService)
explicit

Definition at line 15 of file SessionManager.cpp.

◆ ~SessionManager()

server::SessionManager::~SessionManager ( )
overridedefault

Member Function Documentation

◆ authenticateAndCreateSession()

std::string server::SessionManager::authenticateAndCreateSession ( const std::string &  username,
const std::string &  password 
)

Authenticate and create a session.

Parameters
usernameUsername
passwordPassword
Returns
Session ID if successful, empty string otherwise

Definition at line 17 of file SessionManager.cpp.

References _authService, createSession(), LOG_INFO, and LOG_WARNING.

Here is the call graph for this function:

◆ createSession()

std::shared_ptr< Session > server::SessionManager::createSession ( const std::string &  id)
overridevirtual

Create a new session.

Parameters
idSession identifier
Returns
std::shared_ptr<Session>

Implements server::ISessionManager.

Definition at line 32 of file SessionManager.cpp.

References _sessions, LOG_INFO, and LOG_WARNING.

Referenced by authenticateAndCreateSession().

◆ getAuthService()

std::shared_ptr< AuthService > server::SessionManager::getAuthService ( )
inline

Get the auth service.

Returns
Shared pointer to AuthService

Definition at line 43 of file SessionManager.hpp.

References _authService.

◆ getSession()

std::shared_ptr< Session > server::SessionManager::getSession ( const std::string &  id)
overridevirtual

Get session by ID.

Parameters
idSession identifier
Returns
std::shared_ptr<Session>

Implements server::ISessionManager.

Definition at line 45 of file SessionManager.cpp.

References _sessions.

◆ removeSession()

void server::SessionManager::removeSession ( const std::string &  id)
overridevirtual

Remove session by ID.

Parameters
idSession identifier

Implements server::ISessionManager.

Definition at line 53 of file SessionManager.cpp.

References _sessions, and LOG_INFO.

Member Data Documentation

◆ _authService

std::shared_ptr<AuthService> server::SessionManager::_authService
private

Definition at line 47 of file SessionManager.hpp.

Referenced by authenticateAndCreateSession(), and getAuthService().

◆ _sessions

std::unordered_map<std::string, std::shared_ptr<Session> > server::SessionManager::_sessions
private

Definition at line 46 of file SessionManager.hpp.

Referenced by createSession(), getSession(), and removeSession().


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