Updated Whisper Push Notifications (markdown)

Victor Farazdagi 2017-04-11 15:15:53 +03:00
parent 30a3bb1a11
commit 32aa3a6433
1 changed files with 28 additions and 3 deletions

@ -56,6 +56,8 @@ Original workflow for discovery mechanism was introduced in:
[![image](https://cloud.githubusercontent.com/assets/188194/24608168/19317cdc-187e-11e7-995e-2adadc17a91c.png)](https://cloud.githubusercontent.com/assets/188194/24608168/19317cdc-187e-11e7-995e-2adadc17a91c.png)
### 1. Discovery request and Notification Server selection
Everything starts with `Device A` willing to register with some Notification Service Provider. To do so, it sends/broadcasts discovery request:
```js
@ -113,8 +115,31 @@ watchProposeServerResponses(identity);
```
Now, whenever we receive server proposal and willing to accept it, `sendAcceptServerRequest()` message needs to be broadcasted (so that server knows we have selected it):
# Sharing the key
```js
var acceptServerTopic = '0x04f7dea6'; // ACCEPT_NOTIFICATION_SERVER
var sendAcceptServerRequest = function (identity, serverID) {
// whenever we are ready to accept server, having a given serverID, we need
// to notify it by sending signed (from us) acceptance message.
var err = web3.shh.post({
from: identity, // it is absolutely important to identify the client, or your acceptance will be dropped
topics: [acceptServerTopic],
payload: '{"server": "' + serverID + '"}',
ttl: 20,
keyname: keyname
});
if (err !== null) {
console.log("message NOT sent")
} else {
console.log("message sent OK")
}
};
```
# One-to-One Chats
### 2. Creating Chat session and registering device
# Grop Chats
### 3. Sharing Chat session key, and allowing notifications
# Implementation notes I: One-to-One Chats
# Implementation notes II: Group Chats