@steelbreeze/broker
Version:
Lightweight publish and subscribe using Server-Sent Events for node and express
13 lines (10 loc) • 396 B
JavaScript
const broker = require('@steelbreeze/broker');
// create a client to the message broker
var client = broker.client({host:'localhost', port: 1024, path: '/events'});
// publish a message on the devices topic of the /events broker every second
var timer = setInterval( () => {
client.publish('devices', `Hello at ${new Date()}`, onError);
}, 1000);
function onError() {
clearInterval(timer);
}