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

Represents a user session in the system. More...

#include <session.hpp>

Collaboration diagram for session:
Collaboration graph

Public Member Functions

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

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

Represents a user session in the system.

This is the unified session type that serves both as:

Sessions are stored in a TimescaleDB hypertable for efficient time-series queries and automatic data lifecycle management.

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.