Ditto 4.13.1
 
Loading...
Searching...
No Matches
PresenceGraph.hpp
1#ifndef DITTO_PRESENCE_GRAPH_H
2#define DITTO_PRESENCE_GRAPH_H
3
4#include "Helpers.hpp"
5#include "any.hpp"
6
7#include "json.hpp"
8
9#include <vector>
10
11// TODO(v5): move these aliases into the ditto namespace
12using SiteId = uint64_t;
13using Pubkey = std::vector<uint8_t>;
14
15namespace ditto {
16
17// TODO(v5): remove this using. We don't want `nlohmann::json` to be included
18// in the `ditto` namespace for all code that includes this header. (But
19// removing it in v4.x would be a breaking change.) (SDKS-1124)
20using nlohmann::json;
21
25class DittoAddress {
26public:
27 DittoAddress();
28 DittoAddress(Pubkey pubkey, SiteId site_id);
29 void update_from_json(nlohmann::json j);
30 bool operator==(const DittoAddress &b) const;
31
32private:
33 SiteId site_id;
34 Pubkey pubkey;
35};
36
40class Connection {
41public:
42 Connection();
43
44 // Disable the deprecation warnings for the special member functions which
45 // implicitly copy or move deprecated members.
46#pragma GCC diagnostic push
47#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
48 Connection(const Connection &other) = default;
49 Connection(Connection &&other) = default;
50 Connection &operator=(const Connection &other) = default;
51 Connection &operator=(Connection &&other) = default;
52 ~Connection() = default;
53#pragma GCC diagnostic pop
54
59 std::string id;
60
64 DITTO_DEPRECATED_BECAUSE("Use `peer_key_string1` instead.")
65 Pubkey peer1;
66
70 DITTO_DEPRECATED_BECAUSE("Use `peer_key_string2` instead.")
71 Pubkey peer2;
72
79 std::string peer_key_string1;
80
88 std::string peer_key_string2;
89
97
101 std::string connection_type; // FIXME: use a dedicated `enum` type.
102};
103
107class Peer {
108public:
109 Peer();
110
111 // Disable the deprecation warnings for the special member functions which
112 // implicitly copy or move deprecated members.
113#pragma GCC diagnostic push
114#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
115 Peer(const Peer &other) = default;
116 Peer(Peer &&other) = default;
117 Peer &operator=(const Peer &other) = default;
118 Peer &operator=(Peer &&other) = default;
119 ~Peer() = default;
120#pragma GCC diagnostic pop
121
126
130 DITTO_DEPRECATED_BECAUSE("use `peer_key_string` instead")
131 std::vector<uint8_t> peer_key;
132
140 std::string peer_key_string;
141
147 std::string device_name;
148
152 std::string os;
153
157 DITTO_DEPRECATED_BECAUSE("Query overlap groups have been phased out, this "
158 "property always returns 0.")
160
165
170
174 std::string ditto_sdk_version;
175
180
194 nlohmann::json peer_metadata;
195
204};
205
212public:
216 explicit PresenceGraph(nlohmann::json);
217
218 // Disable the deprecation warnings for the special member functions which
219 // implicitly copy or move deprecated members.
220#pragma GCC diagnostic push
221#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
222 PresenceGraph(const PresenceGraph &other) = default;
223 PresenceGraph(PresenceGraph &&other) = default;
224 PresenceGraph &operator=(const PresenceGraph &other) = default;
225 PresenceGraph &operator=(PresenceGraph &&other) = default;
226 ~PresenceGraph() = default;
227#pragma GCC diagnostic pop
228
236
241 std::vector<Peer> remote_peers;
242};
243
244} // namespace ditto
245#endif
Represents a connection between two peers in a Ditto mesh network.
Definition PresenceGraph.hpp:40
std::string id
Unique identifier for the connection.
Definition PresenceGraph.hpp:59
std::string peer_key_string2
The peer key of the peer at the other end of the connection, as a string.
Definition PresenceGraph.hpp:88
std::string peer_key_string1
The peer key of the peer at one end of the connection, as a string.
Definition PresenceGraph.hpp:79
std::string connection_type
Type of transport enabling this connection.
Definition PresenceGraph.hpp:101
Pubkey peer1
The peer key of the peer at one end of the connection.
Definition PresenceGraph.hpp:65
float approximate_distance_in_meters
Estimate of distance to the remote peer.
Definition PresenceGraph.hpp:96
Pubkey peer2
The peer key of the peer at the other end of the connection.
Definition PresenceGraph.hpp:71
Information used to identify a peer.
Definition PresenceGraph.hpp:25
Represent a known peer in the Ditto network.
Definition PresenceGraph.hpp:107
nlohmann::json identity_service_metadata
Metadata associated with the peer by the identity service.
Definition PresenceGraph.hpp:203
std::string peer_key_string
The peer key is a unique identifier for a given peer, equal to or derived from the cryptographic publ...
Definition PresenceGraph.hpp:140
nlohmann::json peer_metadata
Metadata associated with the peer, or empty map by default.
Definition PresenceGraph.hpp:194
std::string os
Operating system of the remote peer.
Definition PresenceGraph.hpp:152
bool is_compatible
Indicates whether the peer is compatible with the current peer.
Definition PresenceGraph.hpp:169
std::string ditto_sdk_version
The Ditto SDK version the peer is running with.
Definition PresenceGraph.hpp:174
std::string device_name
The human-readable device name of the remote peer. This defaults to the hostname but can be manually ...
Definition PresenceGraph.hpp:147
std::vector< Connection > connections
Currently active connections of the peer.
Definition PresenceGraph.hpp:179
bool is_connected_to_ditto_cloud
Indicates whether the peer is connected to Ditto Cloud.
Definition PresenceGraph.hpp:164
uint8_t query_overlap_group
This field is no longer in use and will always be 0.
Definition PresenceGraph.hpp:159
std::vector< uint8_t > peer_key
Definition PresenceGraph.hpp:131
DittoAddress address
Address to contact this peer via Ditto Bus.
Definition PresenceGraph.hpp:125
Peer local_peer
Returns the local peer (usually the peer that is represented by the currently running Ditto instance)...
Definition PresenceGraph.hpp:235
std::vector< Peer > remote_peers
Returns all remote peers known by the local_peer, either directly or via other remote peers.
Definition PresenceGraph.hpp:241
PresenceGraph(nlohmann::json)
Construct a new Presence Graph object.
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19