Radix Relay
Hybrid mesh communications with Signal Protocol encryption
Loading...
Searching...
No Matches
connection_monitor.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <core/events.hpp>
5#include <cstdint>
6#include <memory>
7#include <optional>
8#include <string>
9#include <unordered_map>
10#include <variant>
11
12namespace radix_relay::core {
13
15{
17 std::string url;
18 std::string error;
19 std::uint64_t timestamp;
20};
21
23{
24 std::optional<transport_state> internet;
25 std::optional<transport_state> bluetooth;
26};
27
29{
30public:
31 // Type traits for standard_processor
33
35 {
36 std::shared_ptr<async::async_queue<events::display_filter_input_t>> display;
37 };
38
39 explicit connection_monitor(const out_queues_t &queues) : display_out_queue_(queues.display) {}
40
41 // Variant handler for standard_processor
42 auto handle(const events::connection_monitor::in_t &event) -> void
43 {
44 std::visit([this](const auto &evt) { this->handle(evt); }, event);
45 }
46
47 auto handle(const events::transport::connected &event) -> void;
48 auto handle(const events::transport::connect_failed &event) -> void;
49 auto handle(const events::transport::disconnected &event) -> void;
50 auto handle(const events::transport::send_failed &event) -> void;
52
53 [[nodiscard]] auto get_status() const -> connection_status;
54
55private:
56 std::shared_ptr<async::async_queue<events::display_filter_input_t>> display_out_queue_;
57 std::unordered_map<events::transport_type, transport_state> states_;
58};
59
60}// namespace radix_relay::core
auto handle(const events::transport::send_failed &event) -> void
auto handle(const events::transport::connect_failed &event) -> void
auto handle(const events::connection_monitor::query_status &event) -> void
auto handle(const events::transport::disconnected &event) -> void
auto handle(const events::transport::connected &event) -> void
auto handle(const events::connection_monitor::in_t &event) -> void
connection_monitor(const out_queues_t &queues)
auto get_status() const -> connection_status
std::variant< transport::connected, transport::connect_failed, transport::disconnected, transport::send_failed, query_status > in_t
Variant type for connection monitor input events.
Definition events.hpp:302
std::shared_ptr< async::async_queue< events::display_filter_input_t > > display
std::optional< transport_state > bluetooth
std::optional< transport_state > internet
Notification of failed connection attempt.
Definition events.hpp:232
Notification of successful connection.
Definition events.hpp:225
Notification of failed send attempt.
Definition events.hpp:254