jami-docs

Forked version of Jami documentation, see wrycode.com/jami-docs-demo
git clone git://git.wrycode.com/wrycode/jami-docs.git
Log | Files | Refs

sync-protocol.md (4212B)


      1 # Sync protocol
      2 
      3 The swarm chat provides new possibilities for every device. Now, it's
      4 possible to sync history between devices by sharing the related
      5 repository. Devices sync needs to be redefined to follow those
      6 changes.
      7 
      8 A lot of scenarios are defined in the [RFC for
      9 swarms](https://git.jami.net/savoirfairelinux/ring-project/wikis/Group-chat-feature-(design-draft)),
     10 however, this doesn't imply for syncing conversations between devices
     11 for the same user. Some new scenarios must be written.
     12 
     13 ## Old method
     14 
     15 Device sync were done via the DHT. Because every value MUST NOT exceed
     16 64k, conversations were not sent in device sync, nor member profiles,
     17 because it's too heavy. This is a problem and MUST be improved.
     18 
     19 In the old method, the daemon is listening on "inbox:DEVICE_ID" for
     20 DeviceSync values which contains the contact list to sync (cf
     21 `AccountManager::startSync()`);
     22 
     23 **NOTE:** The curretn **DeviceSync** value present on the **DHT** is deprecated with this draft.
     24 
     25 ## New method
     26 
     27 Since Jami has the
     28 [ConnectionManager](https://git.jami.net/savoirfairelinux/ring-project/wikis/technical/5.2.%20The%20connection%20manager),
     29 using p2p socket is possible to perform sync quickly with big values
     30 (cause the socket is not limited in data)
     31 
     32 Now, this is the scenario used to sync:
     33 
     34 1. When the device (*A*) goes online, it announces its presence via a DeviceAnnouncement like the OldMethod
     35 2. Other devices (*!A*) will detect that announce and will ask this device through the **ConnectionManager** to open a new channel named "sync://DEVICE_ID_A". (Note: A will get announcement from other devices, so it will asks for sync channels too).
     36 3. As soon as this channel is opened, the device which is asking this channel will send a **DeviceSync** (cf next part) value containing its known conversations and contacts.
     37 4. *A* will check the **DeviceSync** value and:
     38 	+ Remove contacts if it detects removed contacts
     39 	+ Add contacts if it detects added contacts
     40 	+ Remove conversations if it detects removed conversations
     41 	+ Add conversations if it detects added conversations
     42 	+ Remove conversation's requests if request is accepted (now in conversations)/declined
     43 	+ Add conversation's requests if detected
     44 
     45 Note: If *A* detects new conversations, it will asks the device which announced that conversation to clone the repository through a git channel (so like described in [Swarm chat design](https://git.jami.net/savoirfairelinux/ring-project/wikis/Group-chat-feature-(design-draft)))
     46 
     47 ## Device Sync
     48 
     49 This value is a JSON containing:
     50 
     51 ```json
     52 {
     53 	"contacts": [/* Contacts (TODO) */],
     54 	"conversation": [
     55 		{ "id":"convID", "created":TIMESTAMP, "removed":OPTIONAL_TIMESTAMP },
     56 		{ "id":"convID2", "created":TIMESTAMP2, "removed":OPTIONAL_TIMESTAMP2 } /* ... */
     57 	],
     58 	"conversationsRequests": [
     59 		{ "id":"convID", "received":TIMESTAMP, "declined":OPTIONAL_TIMESTAMP,
     60 		  "members":[], "metadatas:[] },
     61 		{ "id":"convID2", "received":TIMESTAMP2, "declined":OPTIONAL_TIMESTAMP2
     62 		  "members":[], "metadatas:[] } /* ... */
     63 	],
     64 }
     65 ```
     66 
     67 ## User stories
     68 
     69 ### Sync when adding device
     70 
     71 + Alice creates a conversation
     72 + (Optional) Alice add some messages
     73 + Alice adds another device
     74 + The other device should receives and sync the conversation previously created
     75 
     76 ### Sync when connect a device
     77 
     78 + Alice creates a conversation
     79 + (Optional) Alice add some messages
     80 + Alice connects another device
     81 + The other device should receives and sync the conversation previously created
     82 
     83 ### Sync between multiple devices
     84 
     85 + Alice got 2 devices
     86 + Alice creates a conversation
     87 + The other device should receives and sync the conversation created on one of the devices
     88 
     89 ### Sync for detecting new requests
     90 
     91 + Alice receives a conversation's request
     92 + Alice add a new device
     93 + The other device should retrieve the requests from device A
     94 
     95 ### Sync for accepted requests
     96 
     97 + Alice has 2 devices
     98 + Alice accepts a conversation's request
     99 + The other device should detect the accepted request
    100 
    101 ### Sync for decline requests
    102 
    103 + Alice has 2 devices
    104 + Alice declines a conversation's request
    105 + The other device should detect the declined request
    106 
    107 ## Current implementation
    108 
    109 https://review.jami.net/c/ring-daemon/+/15584 implements this page