Ditto 4.11.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
20class DittoAddress {
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
35class Connection {
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
102 DITTO_DEPRECATED_BECAUSE("use `peer_key_string` instead")
103 std::vector<uint8_t> peer_key;
104
112 std::string peer_key_string;
113
119 std::string device_name;
120
124 std::string os;
125
129 DITTO_DEPRECATED_BECAUSE("Query overlap groups have been phased out, this "
130 "property always returns 0.")
131 uint8_t query_overlap_group;
132
137
142
146 std::string ditto_sdk_version;
147
152
166 nlohmann::json peer_metadata;
167
176};
177
184public:
188 PresenceGraph(nlohmann::json);
189
197
202 std::vector<Peer> remote_peers;
203};
204
205} // namespace ditto
206#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
nlohmann::json identity_service_metadata
Metadata associated with the peer by the identity service.
Definition PresenceGraph.hpp:175
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:112
DITTO_DEPRECATED_BECAUSE("Query overlap groups have been phased out, this " "property always returns 0.") uint8_t query_overlap_group
This field is no longer in use and will always be 0.
nlohmann::json peer_metadata
Metadata associated with the peer, or empty map by default.
Definition PresenceGraph.hpp:166
std::string os
Operating system of the remote peer.
Definition PresenceGraph.hpp:124
bool is_compatible
Indicates whether the peer is compatible with the current peer.
Definition PresenceGraph.hpp:141
std::string ditto_sdk_version
The Ditto SDK version the peer is running with.
Definition PresenceGraph.hpp:146
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:119
std::vector< Connection > connections
Currently active connections of the peer.
Definition PresenceGraph.hpp:151
bool is_connected_to_ditto_cloud
Indicates whether the peer is connected to Ditto Cloud.
Definition PresenceGraph.hpp:136
std::vector< uint8_t > peer_key
Definition PresenceGraph.hpp:103
DittoAddress address
Address to contact this peer via Ditto Bus.
Definition PresenceGraph.hpp:97
Peer local_peer
Returns the local peer (usually the peer that is represented by the currently running Ditto instance)...
Definition PresenceGraph.hpp:196
std::vector< Peer > remote_peers
Returns all remote peers known by the local_peer, either directly or via other remote peers.
Definition PresenceGraph.hpp:202
PresenceGraph(nlohmann::json)
Construct a new Presence Graph object.
Definition PresenceGraph.cpp:73