Ditto 4.9.4
 
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
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
138
143
147 std::string ditto_sdk_version;
148
153
167 nlohmann::json peer_metadata;
168
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
nlohmann::json identity_service_metadata
Metadata associated with the peer by the identity service.
Definition PresenceGraph.hpp:176
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:113
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:167
std::string os
Operating system of the remote peer.
Definition PresenceGraph.hpp:125
bool is_compatible
Indicates whether the peer is compatible with the current peer.
Definition PresenceGraph.hpp:142
std::string ditto_sdk_version
The Ditto SDK version the peer is running with.
Definition PresenceGraph.hpp:147
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:120
std::vector< Connection > connections
Currently active connections of the peer.
Definition PresenceGraph.hpp:152
bool is_connected_to_ditto_cloud
Indicates whether the peer is connected to Ditto Cloud.
Definition PresenceGraph.hpp:137
std::vector< uint8_t > peer_key
Definition PresenceGraph.hpp:104
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: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
PresenceGraph(nlohmann::json)
Construct a new Presence Graph object.
Definition PresenceGraph.cpp:73