Cavoke  1.1.0
A Platform for creating and hosting multiplayer turn-based board games
Loading...
Searching...
No Matches
cavoke::server::model::SessionsStorage Class Reference

Public Member Functions

 SessionsStorage (std::shared_ptr< GameLogicManager > mGameLogicManager, std::shared_ptr< GamesStorage > mGamesStorage, std::shared_ptr< GameStateStorage > mGameStateStorage)
 
GameSessionAccessObject::GameSessionInfo create_session (const GameConfig &game_config, const std::string &host_user_id, const std::string &room_id="")
 Creates session for given user with given game_config.
 
void start_session (const std::string &session_id, std::optional< json > game_settings)
 Starts session with given settings.
 
GameSessionAccessObject::GameSessionInfo join_session (const std::string &invite_code, const std::string &user_id, std::optional< int > player_id={})
 Tries to connect given user into a session.
 
cavoke::ValidationResult validate_session (const std::string &session_id, std::optional< json > game_settings)
 Validates the settings for given session.
 
GameSessionAccessObject get_sessionAO (const std::string &session_id, drogon::orm::DbClientPtr dbClient=drogon::app().getDbClient())
 Gets an access object for given session.
 

Friends

class GameSessionAccessObject
 

Detailed Description

Definition at line 11 of file sessions_storage.h.

Constructor & Destructor Documentation

◆ SessionsStorage()

cavoke::server::model::SessionsStorage::SessionsStorage ( std::shared_ptr< GameLogicManager mGameLogicManager,
std::shared_ptr< GamesStorage mGamesStorage,
std::shared_ptr< GameStateStorage mGameStateStorage 
)

Definition at line 138 of file sessions_storage.cpp.

Member Function Documentation

◆ create_session()

GameSessionAccessObject::GameSessionInfo cavoke::server::model::SessionsStorage::create_session ( const GameConfig game_config,
const std::string &  host_user_id,
const std::string &  room_id = "" 
)

Creates session for given user with given game_config.

Creates a session with given game config.

Throws game_session_error if errors arise

Returns
session info

Definition at line 21 of file sessions_storage.cpp.

◆ get_sessionAO()

GameSessionAccessObject cavoke::server::model::SessionsStorage::get_sessionAO ( const std::string &  session_id,
drogon::orm::DbClientPtr  dbClient = drogon::app().getDbClient() 
)

Gets an access object for given session.

Gets a session for given session id

Throws game_session_error if no such session

Definition at line 169 of file sessions_storage.cpp.

◆ join_session()

GameSessionAccessObject::GameSessionInfo cavoke::server::model::SessionsStorage::join_session ( const std::string &  session_id,
const std::string &  user_id,
std::optional< int >  player_id = {} 
)

Tries to connect given user into a session.

Joins a session by id

Throws game_session_error if errors arise

Returns
session info

Definition at line 127 of file sessions_storage.cpp.

◆ start_session()

void cavoke::server::model::SessionsStorage::start_session ( const std::string &  session_id,
std::optional< json >  game_settings 
)

Starts session with given settings.

Definition at line 95 of file sessions_storage.cpp.

◆ validate_session()

cavoke::ValidationResult cavoke::server::model::SessionsStorage::validate_session ( const std::string &  session_id,
std::optional< json >  game_settings 
)

Validates the settings for given session.

Definition at line 146 of file sessions_storage.cpp.

Friends And Related Function Documentation

◆ GameSessionAccessObject

friend class GameSessionAccessObject
friend

Definition at line 47 of file sessions_storage.h.


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