grenache-nodejs-ws
Version:
Granache Nodejs Websocket implementation
29 lines (21 loc) • 624 B
JavaScript
// make sure you start 2 grapes
// grape --dp 20001 --aph 30001 --bn '127.0.0.1:20002'
// grape --dp 20002 --aph 40001 --bn '127.0.0.1:20001'
const Grenache = require('./../')
const Link = require('grenache-nodejs-link')
const PeerPub = Grenache.PeerPub
const link = new Link({
grape: 'http://127.0.0.1:30001'
})
link.start()
const peer = new PeerPub(link, {})
peer.init()
const service = peer.transport('server')
service.listen(Math.floor(Math.random() * 1001) + 1024)
setInterval(function () {
link.announce('pub_test', service.port, {})
}, 1000)
setInterval(() => {
service.pub('world')
}, 100)