Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
How it works ?
const pubSub = new PubSubClient('ws://localhost:3001', { connect: true, reconnect: true, }) const topicName = 'abc' pubSub.subscribe(topicName, (message) => { console.log(`Got message from topic ${topicName}`, message) }) //publish a message to topic pubSub.publish(topicName, {title: 'Hello subscribers in the topic abc', body: 'How are you ?'}) // Broadcast send message to subscribers but not me pubSub.broadcast(topicName, {body: 'this is broadcast message'})
Part 1: WebSocket Client and WebSocket Server
Part 2: Subscription : Publish, Subscribe, Broadcast
Part 3: Implement auto reconnect
Github: https://github.com/tabvn/pubsub
Create your own PubSub Client & Server use WebSocket was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Publication date
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.