EmbarkJS - Communication (Whisper, Orbit)ΒΆ


For Whisper:


For Orbit:

You’ll need to use IPFS from master and run it as: ipfs daemon --enable-pubsub-experiment

then set the provider:

EmbarkJS.Messages.setProvider('orbit', {server: 'localhost', port: 5001})

listening to messages

EmbarkJS.Messages.listenTo({topic: ["topic1", "topic2"]}).then(function(message) { console.log("received: " + message); })

sending messages

you can send plain text

EmbarkJS.Messages.sendMessage({topic: "sometopic", data: 'hello world'})

or an object

EmbarkJS.Messages.sendMessage({topic: "sometopic", data: {msg: 'hello world'}})

note: array of topics are considered an AND. In Whisper you can use another array for OR combinations of several topics e.g ["topic1", ["topic2", "topic3"]] => topic1 AND (topic2 OR topic 3)