ORE Studio 0.0.4
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
server_session Class Referencefinal

Represents a client session on the server side. More...

#include <server_session.hpp>

Collaboration diagram for server_session:
Collaboration graph

Classes

struct  pending_database_status
 Pending database status notification to be sent to client. More...
 
struct  pending_notification
 Pending notification to be sent to client. More...
 

Public Member Functions

 server_session (std::unique_ptr< connection > conn, std::string server_id, std::shared_ptr< messaging::message_dispatcher > dispatcher, boost::asio::any_io_executor io_executor, std::shared_ptr< service::subscription_manager > subscription_mgr=nullptr)
 Construct a session from a connection.
 
boost::asio::awaitable< void > run ()
 Run the session.
 
void stop ()
 Stop the session by closing its connection.
 
bool queue_notification (const std::string &event_type, std::chrono::system_clock::time_point timestamp)
 Queue a notification to be sent to this session's client.
 
bool queue_database_status (bool available, const std::string &error_message, std::chrono::system_clock::time_point timestamp)
 Queue a database status notification to be sent to this client.
 

Detailed Description

Represents a client session on the server side.

Manages the lifecycle of a single client connection, including handshake, message processing, and cleanup.

Constructor & Destructor Documentation

◆ server_session()

server_session ( std::unique_ptr< connection conn,
std::string  server_id,
std::shared_ptr< messaging::message_dispatcher dispatcher,
boost::asio::any_io_executor  io_executor,
std::shared_ptr< service::subscription_manager subscription_mgr = nullptr 
)
explicit

Construct a session from a connection.

Parameters
connThe connection to manage
server_idServer identifier for handshake
dispatcherMessage dispatcher for handling requests
io_executorThe executor to use for async operations
subscription_mgrOptional subscription manager for event notifications

Member Function Documentation

◆ run()

boost::asio::awaitable< void > run ( )

Run the session.

Performs handshake and processes messages until connection closes.

◆ stop()

void stop ( )

Stop the session by closing its connection.

This will cause any pending I/O operations to fail and the session to end.

◆ queue_notification()

bool queue_notification ( const std::string &  event_type,
std::chrono::system_clock::time_point  timestamp 
)

Queue a notification to be sent to this session's client.

Thread-safe. The notification will be sent on the next iteration of the message processing loop.

Parameters
event_typeThe event type that occurred.
timestampThe timestamp of the event.
Returns
true if queued successfully, false if session is not active.

◆ queue_database_status()

bool queue_database_status ( bool  available,
const std::string &  error_message,
std::chrono::system_clock::time_point  timestamp 
)

Queue a database status notification to be sent to this client.

Thread-safe. Used to inform the client of database availability status.

Parameters
availableWhether the database is available.
error_messageError message if unavailable, empty otherwise.
timestampThe timestamp of the status check.
Returns
true if queued successfully, false if session is not active.