48 inline static std::string_view logger_name =
"ores.comms.net.server_session";
52 static auto instance = make_logger(logger_name);
61 std::string event_type;
62 std::chrono::system_clock::time_point timestamp;
63 std::vector<std::string> entity_ids;
71 std::string error_message;
72 std::chrono::system_clock::time_point timestamp;
85 explicit server_session(std::unique_ptr<connection> conn, std::string server_id,
86 std::shared_ptr<messaging::message_dispatcher> dispatcher,
87 boost::asio::any_io_executor io_executor,
88 std::shared_ptr<service::auth_session_service> sessions,
89 std::shared_ptr<service::subscription_manager> subscription_mgr =
nullptr);
96 boost::asio::awaitable<void>
run();
117 std::chrono::system_clock::time_point timestamp,
118 const std::vector<std::string>& entity_ids = {});
131 std::chrono::system_clock::time_point timestamp);
139 boost::asio::awaitable<bool> perform_handshake();
144 boost::asio::awaitable<void> process_messages();
152 boost::asio::awaitable<void> run_notification_writer();
160 boost::asio::awaitable<void> send_pending_notifications();
167 boost::asio::awaitable<void> send_pending_database_status();
174 boost::asio::awaitable<void> write_frame_serialized(
const messaging::frame& frame);
179 void register_with_subscription_manager();
184 void unregister_from_subscription_manager();
186 std::unique_ptr<connection> conn_;
187 std::string server_id_;
188 std::shared_ptr<messaging::message_dispatcher> dispatcher_;
189 std::shared_ptr<service::auth_session_service> sessions_;
190 std::shared_ptr<service::subscription_manager> subscription_mgr_;
191 std::uint32_t sequence_number_;
192 bool handshake_complete_;
193 std::atomic<bool> active_{
false};
196 boost::asio::strand<boost::asio::any_io_executor> write_strand_;
199 std::atomic<bool> write_in_progress_{
false};
202 boost::asio::steady_timer notification_signal_;
205 mutable std::mutex notification_mutex_;
206 std::queue<pending_notification> pending_notifications_;
207 std::queue<pending_database_status> pending_database_status_;
bool queue_notification(const std::string &event_type, std::chrono::system_clock::time_point timestamp, const std::vector< std::string > &entity_ids={})
Queue a notification to be sent to this session's client.
Definition server_session.cpp:67
bool queue_database_status(bool available, const std::string &error_message, std::chrono::system_clock::time_point timestamp)
Queue a database status notification to be sent to this client.
Definition server_session.cpp:91