20#ifndef ORES_IAM_DOMAIN_SESSION_HPP
21#define ORES_IAM_DOMAIN_SESSION_HPP
27#include <boost/uuid/uuid.hpp>
28#include <boost/asio/ip/address.hpp>
54 default:
return "unknown";
82 boost::uuids::uuid
id;
99 std::optional<std::chrono::system_clock::time_point>
end_time;
158 [[nodiscard]] std::optional<std::chrono::seconds>
duration()
const {
162 return std::chrono::duration_cast<std::chrono::seconds>(
Domain types for identity and access management.
Definition account.hpp:27
constexpr std::string_view to_string(session_protocol p)
Converts a session_protocol to its string representation.
Definition session.hpp:50
session_protocol
Protocol used for the session connection.
Definition session.hpp:35
@ http
HTTP/REST API with JWT authentication.
@ binary
ORE Studio binary protocol over TCP.
constexpr session_protocol session_protocol_from_string(std::string_view s)
Converts a string to session_protocol.
Definition session.hpp:62
Represents a user session in the system.
Definition session.hpp:78
std::optional< std::chrono::seconds > duration() const
Calculates the session duration.
Definition session.hpp:158
std::optional< std::chrono::system_clock::time_point > end_time
Timestamp when the session ended (logout or disconnect).
Definition session.hpp:99
std::string client_identifier
Client identifier string from handshake.
Definition session.hpp:111
std::uint16_t client_version_major
Client protocol version major number.
Definition session.hpp:116
std::uint64_t bytes_sent
Total bytes sent to the client during this session.
Definition session.hpp:126
boost::asio::ip::address client_ip
Client IP address.
Definition session.hpp:104
boost::uuids::uuid account_id
Foreign key referencing the associated account.
Definition session.hpp:87
session_protocol protocol
Protocol used for this session (binary or HTTP).
Definition session.hpp:143
std::uint16_t client_version_minor
Client protocol version minor number.
Definition session.hpp:121
std::string username
Username of the account that owns this session.
Definition session.hpp:151
std::uint64_t bytes_received
Total bytes received from the client during this session.
Definition session.hpp:131
boost::uuids::uuid id
Unique identifier for this session.
Definition session.hpp:82
std::chrono::system_clock::time_point start_time
Timestamp when the session started (login time).
Definition session.hpp:92
std::string country_code
ISO 3166-1 alpha-2 country code from geolocation.
Definition session.hpp:138
bool is_active() const
Checks if the session is still active.
Definition session.hpp:169
Aggregated session statistics for a time period.
Definition session.hpp:177
double avg_bytes_received
Average bytes received per session.
Definition session.hpp:221
double avg_bytes_sent
Average bytes sent per session.
Definition session.hpp:216
std::chrono::system_clock::time_point period_end
End of the time period.
Definition session.hpp:186
boost::uuids::uuid account_id
Account ID if statistics are per-account, nil for aggregate.
Definition session.hpp:191
std::uint32_t unique_countries
Number of unique countries from which sessions originated.
Definition session.hpp:226
std::uint64_t total_bytes_sent
Total bytes sent across all sessions.
Definition session.hpp:206
std::chrono::system_clock::time_point period_start
Start of the time period.
Definition session.hpp:181
std::uint64_t session_count
Total number of sessions in this period.
Definition session.hpp:196
double avg_duration_seconds
Average session duration in seconds.
Definition session.hpp:201
std::uint64_t total_bytes_received
Total bytes received across all sessions.
Definition session.hpp:211