ORE Studio 0.0.4
Loading...
Searching...
No Matches
subscription_handler.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_COMMS_SERVICE_SUBSCRIPTION_HANDLER_HPP
21#define ORES_COMMS_SERVICE_SUBSCRIPTION_HANDLER_HPP
22
23#include <memory>
24#include "ores.utility/log/make_logger.hpp"
25#include "ores.comms/messaging/message_handler.hpp"
26#include "ores.comms/service/subscription_manager.hpp"
27
28namespace ores::comms::service {
29
40private:
41 [[nodiscard]] static auto& lg() {
42 using namespace ores::utility::log;
43 static auto instance = make_logger(
44 "ores.comms.service.subscription_handler");
45 return instance;
46 }
47
48public:
54 explicit subscription_handler(
55 std::shared_ptr<subscription_manager> manager);
56
65 boost::asio::awaitable<std::expected<std::vector<std::byte>, messaging::error_code>>
66 handle_message(messaging::message_type type,
67 std::span<const std::byte> payload,
68 const std::string& remote_address) override;
69
70private:
74 std::expected<std::vector<std::byte>, messaging::error_code>
75 handle_subscribe_request(std::span<const std::byte> payload,
76 const std::string& remote_address);
77
81 std::expected<std::vector<std::byte>, messaging::error_code>
82 handle_unsubscribe_request(std::span<const std::byte> payload,
83 const std::string& remote_address);
84
85 std::shared_ptr<subscription_manager> manager_;
86};
87
88}
89
90#endif
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
Abstract interface for handling messages from a subsystem.
Definition message_handler.hpp:66
Message handler for subscription protocol messages.
Definition subscription_handler.hpp:39
boost::asio::awaitable< std::expected< std::vector< std::byte >, messaging::error_code > > handle_message(messaging::message_type type, std::span< const std::byte > payload, const std::string &remote_address) override
Handle a subscription protocol message.
Definition subscription_handler.cpp:34