Radix Relay
Hybrid mesh communications with Signal Protocol encryption
Loading...
Searching...
No Matches
events.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <concepts>
4#include <cstddef>
5#include <cstdint>
6#include <optional>
7#include <string>
8#include <variant>
9#include <vector>
10
12
14struct help
15{
16};
17
19struct peers
20{
21};
22
24struct status
25{
26};
27
30{
31};
32
35{
36};
37
39struct scan
40{
41};
42
44struct version
45{
46};
47
49struct mode
50{
51 std::string new_mode;
52};
53
55struct send
56{
57 std::string peer;
58 std::string message;
59};
60
63{
64 std::string message;
65};
66
68struct connect
69{
70 std::string relay;
71};
72
75{
76};
77
80{
81};
82
85{
86};
87
89struct trust
90{
91 std::string peer;
92 std::string alias;
93};
94
96struct verify
97{
98 std::string peer;
99};
100
102struct chat
103{
104 std::string contact;
105};
106
108struct leave
109{
110};
111
114{
115 std::string input;
116};
117
120{
121 std::string subscription_json;
122};
123
126{
127};
128
131{
132};
133
136{
137 std::string bundle_data;
138};
139
142{
143 std::string input;
144};
145
148{
149 std::string sender_rdx;
150 std::string sender_alias;
151 std::string content;
152 std::uint64_t timestamp;
154};
155
158{
159 std::string peer_rdx;
160};
161
164{
165 std::string pubkey;
166 std::string bundle_content;
167 std::string event_id;
168};
169
172{
173 std::string pubkey;
174 std::string event_id;
175};
176
179{
180 std::string rdx_fingerprint;
181 std::string nostr_pubkey;
182 std::string event_id;
183};
184
187{
188};
189
192{
193 std::vector<discovered_identity> identities;
194};
195
198{
199 std::string peer;
200 std::string event_id;
202};
203
206{
207 std::string event_id;
209};
210
213{
214 std::string subscription_id;
215};
216
219
221namespace transport {
222
224 struct connect
225 {
226 std::string url;
227 };
228
231 {
232 std::string url;
234 };
235
238 {
239 std::string url;
240 std::string error_message;
242 };
243
245 struct send
246 {
247 std::string message_id;
248 std::vector<std::byte> bytes;
249 };
250
252 struct sent
253 {
254 std::string message_id;
256 };
257
260 {
261 std::string message_id;
262 std::string error_message;
264 };
265
268 {
269 std::vector<std::byte> bytes;
270 };
271
274 {
275 };
276
282
284 template<typename T>
285 concept Command = std::same_as<T, connect> or std::same_as<T, send> or std::same_as<T, disconnect>;
286
288 template<typename T>
289 concept Event = std::same_as<T, connected> or std::same_as<T, connect_failed> or std::same_as<T, sent>
290 or std::same_as<T, send_failed> or std::same_as<T, bytes_received> or std::same_as<T, disconnected>;
291
293 using in_t = std::variant<connect, send, disconnect>;
294
295}// namespace transport
296
300 {
301 };
302
304 using in_t = std::variant<transport::connected,
309
310}// namespace connection_monitor
311
313template<typename T>
314concept Command =
315 std::same_as<T, help> or std::same_as<T, peers> or std::same_as<T, status> or std::same_as<T, sessions>
316 or std::same_as<T, identities> or std::same_as<T, scan> or std::same_as<T, version> or std::same_as<T, mode>
317 or std::same_as<T, send> or std::same_as<T, broadcast> or std::same_as<T, connect> or std::same_as<T, disconnect>
318 or std::same_as<T, publish_identity> or std::same_as<T, unpublish_identity> or std::same_as<T, trust>
319 or std::same_as<T, verify> or std::same_as<T, subscribe> or std::same_as<T, subscribe_identities>
320 or std::same_as<T, subscribe_messages> or std::same_as<T, establish_session> or std::same_as<T, chat>
321 or std::same_as<T, leave> or std::same_as<T, unknown_command>;
322
324template<typename T>
326 std::same_as<T, message_received> or std::same_as<T, session_established>
327 or std::same_as<T, bundle_announcement_received> or std::same_as<T, bundle_announcement_removed>
328 or std::same_as<T, message_sent> or std::same_as<T, bundle_published> or std::same_as<T, subscription_established>
329 or std::same_as<T, identities_listed>;
330
340
342template<typename T>
343concept Event = Command<T> or PresentationEvent<T> or std::same_as<T, raw_command>;
344
378
381{
390
391 std::string message;
392 std::optional<std::string> contact_rdx{};
393 std::uint64_t timestamp{ 0 };
395};
396
399{
400 std::string rdx_fingerprint;
401 std::string display_name;
402};
403
406{
407};
408
410using display_filter_input_t = std::variant<display_message, enter_chat_mode, exit_chat_mode>;
411
413using ui_event_t = std::variant<display_message, enter_chat_mode, exit_chat_mode>;
414
415}// namespace radix_relay::core::events
Concept for user command event types.
Definition events.hpp:314
Concept for all event types.
Definition events.hpp:343
Concept for presentation layer event types.
Definition events.hpp:325
Concept for transport command types.
Definition events.hpp:285
Concept for transport event types.
Definition events.hpp:289
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:308
std::variant< send, publish_identity, unpublish_identity, trust, subscribe, subscribe_identities, subscribe_messages, list_identities > command_from_main_variant_t
Variant of commands from main to session orchestrator.
Definition events.hpp:356
std::variant< send, publish_identity, unpublish_identity, trust, subscribe, subscribe_identities, subscribe_messages, list_identities, connect, transport::bytes_received, transport::connected, transport::connect_failed, transport::sent, transport::send_failed, transport::disconnected, bundle_announcement_received, bundle_announcement_removed > in_t
Variant of all input events to session orchestrator.
Definition events.hpp:375
std::variant< connect, send, disconnect > in_t
Variant type for transport input events.
Definition events.hpp:293
transport_type
Transport type discriminator.
Definition events.hpp:218
std::variant< message_received, session_established, bundle_announcement_received, bundle_announcement_removed, message_sent, bundle_published, subscription_established, identities_listed > presentation_event_variant_t
Variant type for presentation events.
Definition events.hpp:339
std::variant< display_message, enter_chat_mode, exit_chat_mode > ui_event_t
UI events: unified event stream for UI layers (replaces separate display + control queues)
Definition events.hpp:413
std::variant< display_message, enter_chat_mode, exit_chat_mode > display_filter_input_t
Display filter input: either a display message or control event.
Definition events.hpp:410
Broadcast message to all peers.
Definition events.hpp:63
std::string message
Message content to broadcast.
Definition events.hpp:64
Notification of received bundle announcement.
Definition events.hpp:164
Notification of removed bundle announcement.
Definition events.hpp:172
Notification of published bundle status.
Definition events.hpp:206
bool accepted
Whether relay accepted the bundle.
Definition events.hpp:208
std::string event_id
Nostr event ID.
Definition events.hpp:207
Enter chat mode with a specific contact.
Definition events.hpp:103
std::string contact
RDX fingerprint, Nostr pubkey, or alias.
Definition events.hpp:104
std::string relay
Relay URL to connect to.
Definition events.hpp:70
Disconnect from current relay.
Definition events.hpp:75
Discovered identity information.
Definition events.hpp:179
std::string rdx_fingerprint
Signal Protocol RDX fingerprint.
Definition events.hpp:180
std::string nostr_pubkey
Nostr public key.
Definition events.hpp:181
Request to display a message to the user.
Definition events.hpp:381
std::optional< std::string > contact_rdx
Associated contact (for filtering)
Definition events.hpp:392
@ incoming_message
Received message from contact.
std::string message
Message content to display.
Definition events.hpp:391
std::uint64_t timestamp
When event occurred (Unix epoch ms)
Definition events.hpp:393
source source_type
Type of message for filtering.
Definition events.hpp:394
Enter chat mode with specified contact.
Definition events.hpp:399
std::string rdx_fingerprint
Contact to chat with.
Definition events.hpp:400
std::string display_name
Display name or alias for UI.
Definition events.hpp:401
Establish session from a received bundle.
Definition events.hpp:136
std::string bundle_data
Base64-encoded prekey bundle.
Definition events.hpp:137
Exit chat mode, return to showing all messages.
Definition events.hpp:406
Request display of available commands.
Definition events.hpp:15
Response containing discovered identities.
Definition events.hpp:192
std::vector< discovered_identity > identities
List of discovered identities.
Definition events.hpp:193
Request list of discovered identities.
Definition events.hpp:35
Request list of all discovered identities.
Definition events.hpp:187
Notification of received encrypted message.
Definition events.hpp:148
std::string sender_alias
Alias of sender (if known)
Definition events.hpp:150
std::string sender_rdx
RDX fingerprint of sender.
Definition events.hpp:149
std::uint64_t timestamp
Message timestamp.
Definition events.hpp:152
bool should_republish_bundle
Whether to republish prekey bundle.
Definition events.hpp:153
std::string content
Decrypted message content.
Definition events.hpp:151
Notification of sent message status.
Definition events.hpp:198
bool accepted
Whether relay accepted the message.
Definition events.hpp:201
std::string peer
RDX fingerprint of recipient.
Definition events.hpp:199
std::string event_id
Nostr event ID.
Definition events.hpp:200
Change operational mode.
Definition events.hpp:50
std::string new_mode
The new mode to switch to.
Definition events.hpp:51
Request list of connected peers.
Definition events.hpp:20
Publish identity bundle to the network.
Definition events.hpp:80
Raw unparsed command input.
Definition events.hpp:142
std::string input
Raw command string.
Definition events.hpp:143
Request scan for nearby peers.
Definition events.hpp:40
Send encrypted message to a specific peer.
Definition events.hpp:56
std::string message
Message content to send.
Definition events.hpp:58
std::string peer
RDX fingerprint or alias of recipient.
Definition events.hpp:57
Notification of successfully established session.
Definition events.hpp:158
std::string peer_rdx
RDX fingerprint of peer.
Definition events.hpp:159
Request list of active sessions.
Definition events.hpp:30
Request current system status.
Definition events.hpp:25
Subscribe to identity announcements.
Definition events.hpp:126
Subscribe to encrypted messages for this node.
Definition events.hpp:131
Subscribe to custom Nostr events.
Definition events.hpp:120
std::string subscription_json
JSON subscription filter.
Definition events.hpp:121
Notification of established subscription.
Definition events.hpp:213
std::string subscription_id
Subscription identifier.
Definition events.hpp:214
Notification of received data from transport.
Definition events.hpp:268
std::vector< std::byte > bytes
Received raw data.
Definition events.hpp:269
Notification of failed connection attempt.
Definition events.hpp:238
transport_type type
Type of transport.
Definition events.hpp:241
std::string url
Transport endpoint URL.
Definition events.hpp:239
Command to connect to a transport endpoint.
Definition events.hpp:225
std::string url
Transport endpoint URL.
Definition events.hpp:226
Notification of successful connection.
Definition events.hpp:231
transport_type type
Type of transport.
Definition events.hpp:233
std::string url
Connected transport endpoint URL.
Definition events.hpp:232
Command to disconnect from transport.
Definition events.hpp:274
transport_type type
Type of transport.
Definition events.hpp:280
Notification of failed send attempt.
Definition events.hpp:260
std::string message_id
Message identifier.
Definition events.hpp:261
transport_type type
Type of transport.
Definition events.hpp:263
Command to send data through transport.
Definition events.hpp:246
std::string message_id
Unique message identifier.
Definition events.hpp:247
std::vector< std::byte > bytes
Raw data to send.
Definition events.hpp:248
Notification of successful send.
Definition events.hpp:253
transport_type type
Type of transport.
Definition events.hpp:255
std::string message_id
Message identifier.
Definition events.hpp:254
Establish trust with a peer and assign an alias.
Definition events.hpp:90
std::string peer
RDX fingerprint of peer to trust.
Definition events.hpp:91
std::string alias
Friendly alias to assign.
Definition events.hpp:92
Unknown or unrecognized command.
Definition events.hpp:114
std::string input
The original unrecognized input.
Definition events.hpp:115
Remove identity bundle from the network.
Definition events.hpp:85
Verify identity fingerprint of a peer.
Definition events.hpp:97
std::string peer
RDX fingerprint to verify.
Definition events.hpp:98
Request application version information.
Definition events.hpp:45