ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
session_data Struct Referencefinal

Session data owned by ores.comms for protocol-level session tracking. More...

#include <session_data.hpp>

Collaboration diagram for session_data:
Collaboration graph

Public Member Functions

bool is_active () const
 Checks if the session is still active.
 
std::optional< std::chrono::seconds > duration () const
 Calculates the session duration.
 

Public Attributes

boost::uuids::uuid id
 Unique identifier for this session.
 
boost::uuids::uuid account_id
 Foreign key referencing the associated account.
 
std::chrono::system_clock::time_point start_time
 Timestamp when the session started (login time).
 
std::optional< std::chrono::system_clock::time_point > end_time
 Timestamp when the session ended (logout or disconnect).
 
boost::asio::ip::address client_ip
 Client IP address.
 
std::string client_identifier
 Client identifier string from handshake.
 
std::uint16_t client_version_major = 0
 Client protocol version major number.
 
std::uint16_t client_version_minor = 0
 Client protocol version minor number.
 
std::uint64_t bytes_sent = 0
 Total bytes sent to the client during this session.
 
std::uint64_t bytes_received = 0
 Total bytes received from the client during this session.
 
std::string country_code
 ISO 3166-1 alpha-2 country code from geolocation.
 
session_protocol protocol = session_protocol::binary
 Protocol used for this session (binary or HTTP).
 
std::string username
 Username of the account that owns this session.
 

Detailed Description

Session data owned by ores.comms for protocol-level session tracking.

This struct exists to break the circular dependency between ores.comms and ores.iam. Previously, ores.comms depended on ores.iam for the session type, which created a cycle:

ores.comms -> ores.iam -> ores.variability -> ores.comms

By defining session data here in ores.comms, the dependency is inverted: ores.iam now depends on ores.comms (which it does anyway via variability), and provides conversion functions between this struct and its domain::session.

This is a plain data struct with no behavior beyond trivial helpers. The persistence layer (repository, mappers) remains in ores.iam.

Member Function Documentation

◆ duration()

std::optional< std::chrono::seconds > duration ( ) const

Calculates the session duration.

Returns
Duration if session has ended, nullopt if still active.

Member Data Documentation

◆ end_time

std::optional<std::chrono::system_clock::time_point> end_time

Timestamp when the session ended (logout or disconnect).

Empty if session is still active.

◆ client_identifier

std::string client_identifier

Client identifier string from handshake.

Typically contains the client application name.

◆ country_code

std::string country_code

ISO 3166-1 alpha-2 country code from geolocation.

Empty if geolocation is not available or IP is private/localhost.

◆ username

std::string username

Username of the account that owns this session.

Cached here for efficient access without needing to look up the account. Set during login and immutable for the session lifetime.