20#ifndef ORES_COMMS_SERVICE_REMOTE_EVENT_ADAPTER_HPP
21#define ORES_COMMS_SERVICE_REMOTE_EVENT_ADAPTER_HPP
29#include <boost/asio/awaitable.hpp>
30#include "ores.utility/log/make_logger.hpp"
31#include "ores.comms/net/client.hpp"
33namespace ores::comms::service {
49 inline static std::string_view logger_name =
50 "ores.comms.service.remote_event_adapter";
54 static auto instance = make_logger(logger_name);
84 boost::asio::awaitable<bool>
subscribe(
const std::string& event_type);
94 boost::asio::awaitable<bool>
unsubscribe(
const std::string& event_type);
131 void on_notification(
const std::string& event_type,
132 std::chrono::system_clock::time_point timestamp);
134 std::shared_ptr<net::client> client_;
135 mutable std::mutex mutex_;
136 std::set<std::string> subscriptions_;
std::function< void(const std::string &event_type, std::chrono::system_clock::time_point timestamp)> notification_callback_t
Callback invoked when client receives a notification from server.
Definition client.hpp:101
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
Adapts remote server subscriptions to local notification callbacks.
Definition remote_event_adapter.hpp:47
boost::asio::awaitable< bool > subscribe(const std::string &event_type)
Subscribe to notifications for an event type.
Definition remote_event_adapter.cpp:51
boost::asio::awaitable< std::size_t > resubscribe_all()
Re-subscribe to all previously subscribed event types.
Definition remote_event_adapter.cpp:146
boost::asio::awaitable< bool > unsubscribe(const std::string &event_type)
Unsubscribe from notifications for an event type.
Definition remote_event_adapter.cpp:94
std::set< std::string > get_subscriptions() const
Get the set of currently subscribed event types.
Definition remote_event_adapter.cpp:141
bool is_subscribed(const std::string &event_type) const
Check if currently subscribed to an event type.
Definition remote_event_adapter.cpp:136
void set_notification_callback(net::notification_callback_t callback)
Set callback to be invoked when notifications are received.
Definition remote_event_adapter.cpp:185
~remote_event_adapter()
Destructor.
Definition remote_event_adapter.cpp:42