You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The subscribe function is called from a subscriber with node.services.pubsub.subscribe(PEER_SUBSCRIPTION_TOPIC) and the other publishing peer is sending a notification with node.services.pubsub.publish(PEER_SUBSCRIPTION_TOPIC, new Uint8Array(BSON.serialize({ipAddress: argv.ipAddress}).buffer)).
What I notice is that the publishing only works if the subscription of the other peer is know, i.e. if the publish is executed too early before the subscribe is known, publish is not doing anything and any listener node.services.pubsub.addEventListener('message', (message) => {...} is never called in the subscriber. To make it work I have to wait until the publishing peer is connected and I have to use a delay in the publisher like:
setTimeout( () => {
node.services.pubsub.publish(PEER_SUBSCRIPTION_TOPIC, new Uint8Array(BSON.serialize({ipAddress: argv.ipAddress}).buffer))
}, 5000)
What is the correct way to send a message from a publisher, so that a connecting client can receive it without using this delay? is there a callback?
The text was updated successfully, but these errors were encountered:
The subscribe function is called from a subscriber with
node.services.pubsub.subscribe(PEER_SUBSCRIPTION_TOPIC)
and the other publishing peer is sending a notification withnode.services.pubsub.publish(PEER_SUBSCRIPTION_TOPIC, new Uint8Array(BSON.serialize({ipAddress: argv.ipAddress}).buffer))
.What I notice is that the publishing only works if the subscription of the other peer is know, i.e. if the publish is executed too early before the subscribe is known, publish is not doing anything and any listener
node.services.pubsub.addEventListener('message', (message) => {...}
is never called in the subscriber. To make it work I have to wait until the publishing peer is connected and I have to use a delay in the publisher like:What is the correct way to send a message from a publisher, so that a connecting client can receive it without using this delay? is there a callback?
The text was updated successfully, but these errors were encountered: