Ditto 4.8.1-rc.1
Loading...
Searching...
No Matches
PresenceGraph.hpp
1#ifndef _DITTO_PRESENCE_GRAPH_
2#define _DITTO_PRESENCE_GRAPH_
3
4#include "Helpers.hpp"
5#include "any.hpp"
6
7#include "json.hpp"
8
9#include <vector>
10
11typedef uint64_t SiteId;
12typedef std::vector<uint8_t> Pubkey;
13
14namespace ditto {
15using nlohmann::json;
16
21public:
22 explicit DittoAddress();
23 DittoAddress(Pubkey pubkey, SiteId site_id);
24 void update_from_json(json j);
25 bool operator==(const DittoAddress &b) const;
26
27private:
28 SiteId site_id;
29 Pubkey pubkey;
30};
31
36public:
37 explicit Connection();
42 std::string id;
43
47 DITTO_DEPRECATED_BECAUSE("Use `peer_key_string1` instead.")
48 Pubkey peer1;
49
53 DITTO_DEPRECATED_BECAUSE("Use `peer_key_string2` instead.")
54 Pubkey peer2;
55
62 std::string peer_key_string1;
63
71 std::string peer_key_string2;
72
80
84 std::string connection_type; // FIXME: use a dedicated `enum` type.
85};
86
90class Peer {
91public:
92 explicit Peer();
93
98
103 DITTO_DEPRECATED_BECAUSE("use `peer_key_string` instead")
104 std::vector<uint8_t> peer_key;
105
113 std::string peer_key_string;
114
120 std::string device_name;
121
125 std::string os;
126
130 DITTO_DEPRECATED_BECAUSE("Query overlap groups have been phased out, this "
131 "property always returns 0.")
132 uint8_t query_overlap_group;
133
137 bool is_connected_to_ditto_cloud;
138
142 bool is_compatible;
143
147 std::string ditto_sdk_version;
148
152 std::vector<Connection> connections;
153
167 nlohmann::json peer_metadata;
168
176 nlohmann::json identity_service_metadata;
177};
178
185public:
189 PresenceGraph(nlohmann::json);
190
198
203 std::vector<Peer> remote_peers;
204};
205
206} // namespace ditto
207#endif
Represents a connection between two peers in a Ditto mesh network.
Definition PresenceGraph.hpp:35
std::string id
Unique identifier for the connection.
Definition PresenceGraph.hpp:42
std::string peer_key_string2
The peer key of the peer at the other end of the connection, as a string.
Definition PresenceGraph.hpp:71
std::string peer_key_string1
The peer key of the peer at one end of the connection, as a string.
Definition PresenceGraph.hpp:62
std::string connection_type
Type of transport enabling this connection.
Definition PresenceGraph.hpp:84
Pubkey peer1
The peer key of the peer at one end of the connection.
Definition PresenceGraph.hpp:48
float approximate_distance_in_meters
Estimate of distance to the remote peer.
Definition PresenceGraph.hpp:79
Pubkey peer2
The peer key of the peer at the other end of the connection.
Definition PresenceGraph.hpp:54
Information used to identify a peer.
Definition PresenceGraph.hpp:20
Represent a known peer in the Ditto network.
Definition PresenceGraph.hpp:90
DittoAddress address
Address to contact this peer via Ditto Bus.
Definition PresenceGraph.hpp:97
Represents the Ditto mesh network of peers and their connections between each other....
Definition PresenceGraph.hpp:184
Peer local_peer
Returns the local peer (usually the peer that is represented by the currently running Ditto instance)...
Definition PresenceGraph.hpp:197
std::vector< Peer > remote_peers
Returns all remote peers known by the local_peer, either directly or via other remote peers.
Definition PresenceGraph.hpp:203