Open raphael10-collab opened 3 years ago
I'd guess this is only a timing issue - if you call send
within the sub
callback and the other one doesn't get you subscribe message within 200ms it's not repeated. Might be caused by some networking stuff.
I'm here again in order to clarify and understand some aspects of the
hyperpubsub
behaviour .(PC):
(laptop):
let client, server try { client = new Client() await client.ready() } catch(e) { console.log('no hyperspace server running, starting up a new one') server = new Server() await server.ready() client = new Client() await client.ready() } return {client, server} }
const pubsub = new PubSub(client.network, {application: 'example app', onError: console.error})
function send() { pubsub.pub('some topic', Buffer.from('Hello from Marco', 'utf-8')) }
setTimeout(send, 200)
pubsub.sub('some topic', (msg, app) => { setTimeout(send, 200) console.log(msg.toString('utf-8')) })
If I execute
simple_example_without_simulator.js
first on thePC
, and then after few seconds on thelaptop
I get this output (no messages exchange):(PC) :
(laptop):
no hyperspace server running, starting up a new one peer-add 192.168.1.7 <- sub some topic to 192.168.1.7 peer-add ::ffff:192.168.1.7 <- sub some topic to ::ffff:192.168.1.7 -> msg sub some topic from 192.168.1.7 subscriber 192.168.1.7 added to topic some topic peer-remove 192.168.1.7 subscriber 192.168.1.7 removed from topic some topic joined topic "some topic" (bce5935f9a6ade33d955c843f9b906e1b1fe769be6f1757fff6ca0f644506e42) <- sub some topic broadcast
But If I execute
first
on thelaptop
and few seconds later on thePC
I get this output, which is the expected output:(PC) :
(laptop) :
Why does this happen? How to make it work also when I execute first on PC and then after few seconds on the laptop?