Updated Whisper Push Notifications (markdown)
parent
fd048aa334
commit
ba8bc460bd
|
@ -50,7 +50,33 @@ 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)
|
||||
|
||||
Let's give a concrete code example:
|
||||
Everything starts with `Device A` willing to register with some Notification Service Provider, for that discovery request needs to be sent:
|
||||
|
||||
```js
|
||||
var discoverServerTopic = '0x268302f3'; // DISCOVER_NOTIFICATION_SERVER
|
||||
var sendDiscoveryRequest = function (identity) {
|
||||
// notification server discovery request is a signed (sent from us) broadcast,
|
||||
// encrypted with Notification Protocol Symmetric Key (which is publicly known)
|
||||
var err = web3.shh.post({
|
||||
from: identity,
|
||||
topics: [discoverServerTopic],
|
||||
ttl: 20,
|
||||
keyname: 'NOTIFICATION_PROTOCOL_KEY'
|
||||
});
|
||||
if (err !== null) {
|
||||
console.log("message NOT sent")
|
||||
} else {
|
||||
console.log("message sent OK")
|
||||
}
|
||||
};
|
||||
|
||||
var identity = web3.shh.newIdentity();
|
||||
sendDiscoveryRequest(identity);
|
||||
```
|
||||
Once that request is sent all capable wnodes respond back, so we need to watch for their responses, and select one provider (generally FIFO):
|
||||
|
||||
```js
|
||||
```
|
||||
|
||||
# Sharing the key
|
||||
|
||||
|
|
Loading…
Reference in New Issue