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

Client-side session manager providing auth-aware request handling. More...

#include <client_session.hpp>

Collaboration diagram for client_session:
Collaboration graph

Public Member Functions

 client_session (const client_session &)=delete
 
client_sessionoperator= (const client_session &)=delete
 
 client_session (client_session &&)=default
 
client_sessionoperator= (client_session &&)=default
 
std::expected< void, client_session_errorconnect (client_options options)
 Connect to the server.
 
void disconnect ()
 Disconnect from the server.
 
bool is_connected () const noexcept
 Check if connected to server.
 
bool is_logged_in () const noexcept
 Check if logged in.
 
void set_session_info (client_session_info info)
 Set session info after successful login.
 
void clear_session_info () noexcept
 Clear session info on logout.
 
bool is_admin () const noexcept
 Check if logged in as admin.
 
const std::optional< client_session_info > & session_info () const noexcept
 Get current session info if logged in.
 
template<Serializable RequestType, Deserializable ResponseType, messaging::message_type RequestMsgType>
std::expected< ResponseType, client_session_errorprocess_request (RequestType request)
 Process a request that does not require authentication.
 
template<Serializable RequestType, Deserializable ResponseType, messaging::message_type RequestMsgType>
std::expected< ResponseType, client_session_errorprocess_authenticated_request (RequestType request)
 Process a request that requires authentication.
 
template<Serializable RequestType, Deserializable ResponseType, messaging::message_type RequestMsgType>
std::expected< ResponseType, client_session_errorprocess_admin_request (RequestType request)
 Process a request that requires admin privileges.
 

Detailed Description

Client-side session manager providing auth-aware request handling.

This class wraps a net::client and provides:

Designed to be shared between ores.shell and ores.qt clients.

Member Function Documentation

◆ connect()

std::expected< void, client_session_error > connect ( client_options  options)

Connect to the server.

Parameters
optionsConnection options
Returns
Empty expected on success, error on failure
Here is the caller graph for this function:

◆ disconnect()

void disconnect ( )

Disconnect from the server.

Will logout first if logged in.

Here is the caller graph for this function:

◆ set_session_info()

void set_session_info ( client_session_info  info)

Set session info after successful login.

Called by the application layer after processing a login response.

Parameters
infoSession information from login response
Here is the caller graph for this function:

◆ clear_session_info()

void clear_session_info ( )
noexcept

Clear session info on logout.

Called by the application layer after logout or disconnect.

Here is the caller graph for this function:

◆ process_request()

template<Serializable RequestType, Deserializable ResponseType, messaging::message_type RequestMsgType>
std::expected< ResponseType, client_session_error > process_request ( RequestType  request)

Process a request that does not require authentication.

Use this for messages like bootstrap_status_request that don't need login.

Template Parameters
RequestTypeRequest message type (must be Serializable)
ResponseTypeResponse message type (must be Deserializable)
RequestMsgTypeThe message_type enum value for the request
Parameters
requestThe request to send
Returns
Response on success, error on failure
Here is the caller graph for this function:

◆ process_authenticated_request()

template<Serializable RequestType, Deserializable ResponseType, messaging::message_type RequestMsgType>
std::expected< ResponseType, client_session_error > process_authenticated_request ( RequestType  request)

Process a request that requires authentication.

Checks if logged in before sending. Use this for most requests.

Template Parameters
RequestTypeRequest message type (must be Serializable)
ResponseTypeResponse message type (must be Deserializable)
RequestMsgTypeThe message_type enum value for the request
Parameters
requestThe request to send
Returns
Response on success, error on failure (including not_logged_in)
Here is the caller graph for this function:

◆ process_admin_request()

template<Serializable RequestType, Deserializable ResponseType, messaging::message_type RequestMsgType>
std::expected< ResponseType, client_session_error > process_admin_request ( RequestType  request)

Process a request that requires admin privileges.

Checks if logged in as admin before sending.

Template Parameters
RequestTypeRequest message type (must be Serializable)
ResponseTypeResponse message type (must be Deserializable)
RequestMsgTypeThe message_type enum value for the request
Parameters
requestThe request to send
Returns
Response on success, error on failure (including not_logged_in, admin_required)