Update 2.2. Manage contacts
This commit is contained in:
parent
39bcf7a668
commit
ab35c4120d
|
@ -1,10 +1,31 @@
|
|||
This section will present how to find and add a contact from the DHT to the client. The usage of a name server will not be explained here. If you want details about that, please read: https://git.ring.cx/savoirfairelinux/ring-project/wikis/technical/Name-Server-Protocol
|
||||
|
||||
# Presence on the network
|
||||
|
||||
## Announce the presence on the DHT
|
||||
|
||||
The presence is pretty simple to announce on the DHT. In fact, it's just a value containing the device hash (see [previous section](https://git.ring.cx/savoirfairelinux/ring-project/wikis/technical/2.1.-Manage-Accounts)) on the hash corresponding to the Ring ID. So, if we have the account `bf5f1e21d3eb2c1246946aa49d5dcf3e5b9cb1b9` with the device `62fbdff0ce86f368c7d3c2682539e5ba9e06404f`, the following defined value will be sent over the DHT:
|
||||
|
||||
```cpp
|
||||
/**
|
||||
* Device announcement stored on DHT.
|
||||
*/
|
||||
struct RingAccount::DeviceAnnouncement : public dht::SignedValue<DeviceAnnouncement>
|
||||
{
|
||||
private:
|
||||
using BaseClass = dht::SignedValue<DeviceAnnouncement>;
|
||||
public:
|
||||
static const constexpr dht::ValueType& TYPE = dht::ValueType::USER_DATA;
|
||||
dht::InfoHash dev;
|
||||
MSGPACK_DEFINE_MAP(dev);
|
||||
};
|
||||
```
|
||||
|
||||
(This value can be put with `dht_.put(h, VALUE, dht::DoneCallback{}, {}, true);`, as a permanent put). If the device is announced, the device is present. For now, there is no way to delete or edit a value on the DHT (this will come when OpenDHT will supports ECC). So, the presence always have a delay for now (mean delay: expire-time/2, so 2min30 for now).
|
||||
|
||||
## Get if a contact is present
|
||||
|
||||
### Retrieve the devices of a contact
|
||||
Now our presence on the network, it's time to get if somebody is present on the DHT.
|
||||
|
||||
# Send a pending request
|
||||
|
||||
|
|
Loading…
Reference in New Issue