ORE Studio 0.0.4
Loading...
Searching...
No Matches
session_protocol.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_IAM_MESSAGING_SESSION_PROTOCOL_HPP
21#define ORES_IAM_MESSAGING_SESSION_PROTOCOL_HPP
22
23#include <span>
24#include <iosfwd>
25#include <vector>
26#include <expected>
27#include <cstdint>
28#include <boost/uuid/uuid.hpp>
29#include "ores.comms/messaging/message_types.hpp"
30#include "ores.comms/messaging/message_traits.hpp"
31#include "ores.iam/domain/session.hpp"
32
33namespace ores::iam::messaging {
34
42 boost::uuids::uuid account_id; // nil = own sessions
43 std::uint32_t limit = 100; // Max sessions to return
44 std::uint32_t offset = 0; // Pagination offset
45
46 std::vector<std::byte> serialize() const;
47 static std::expected<list_sessions_request, ores::utility::serialization::error_code>
48 deserialize(std::span<const std::byte> data);
49};
50
51std::ostream& operator<<(std::ostream& s, const list_sessions_request& v);
52
57 std::vector<domain::session> sessions;
58 std::uint32_t total_count = 0; // Total available (for pagination)
59
60 std::vector<std::byte> serialize() const;
61 static std::expected<list_sessions_response, ores::utility::serialization::error_code>
62 deserialize(std::span<const std::byte> data);
63};
64
65std::ostream& operator<<(std::ostream& s, const list_sessions_response& v);
66
74 boost::uuids::uuid account_id; // nil = aggregate
75 std::chrono::system_clock::time_point start_time;
76 std::chrono::system_clock::time_point end_time;
77
78 std::vector<std::byte> serialize() const;
79 static std::expected<get_session_statistics_request, ores::utility::serialization::error_code>
80 deserialize(std::span<const std::byte> data);
81};
82
83std::ostream& operator<<(std::ostream& s, const get_session_statistics_request& v);
84
89 std::vector<domain::session_statistics> statistics;
90
91 std::vector<std::byte> serialize() const;
92 static std::expected<get_session_statistics_response, ores::utility::serialization::error_code>
93 deserialize(std::span<const std::byte> data);
94};
95
96std::ostream& operator<<(std::ostream& s, const get_session_statistics_response& v);
97
105 std::vector<std::byte> serialize() const;
106 static std::expected<get_active_sessions_request, ores::utility::serialization::error_code>
107 deserialize(std::span<const std::byte> data);
108};
109
110std::ostream& operator<<(std::ostream& s, const get_active_sessions_request& v);
111
116 std::vector<domain::session> sessions;
117
118 std::vector<std::byte> serialize() const;
119 static std::expected<get_active_sessions_response, ores::utility::serialization::error_code>
120 deserialize(std::span<const std::byte> data);
121};
122
123std::ostream& operator<<(std::ostream& s, const get_active_sessions_response& v);
124
125}
126
127namespace ores::comms::messaging {
128
132template<>
133struct message_traits<iam::messaging::list_sessions_request> {
136 static constexpr message_type request_message_type =
137 message_type::list_sessions_request;
138};
139
143template<>
144struct message_traits<iam::messaging::get_session_statistics_request> {
147 static constexpr message_type request_message_type =
148 message_type::get_session_statistics_request;
149};
150
154template<>
155struct message_traits<iam::messaging::get_active_sessions_request> {
158 static constexpr message_type request_message_type =
159 message_type::get_active_sessions_request;
160};
161
162}
163
164#endif
Contains messaging related infrastructure in the comms library.
Definition assets_protocol.hpp:122
Network messaging infrastructure for the IAM module.
Definition account_history_protocol.hpp:33
Traits template for mapping request types to their response types and message type enum values.
Definition message_traits.hpp:66
Request to list sessions for an account.
Definition session_protocol.hpp:41
Response containing session history.
Definition session_protocol.hpp:56
Request to get session statistics.
Definition session_protocol.hpp:73
Response containing session statistics.
Definition session_protocol.hpp:88
Request to get all active sessions.
Definition session_protocol.hpp:104
Response containing active sessions.
Definition session_protocol.hpp:115