primus-broadcast

1.1.0 • Public • Published

primus-broadcast

npm install primus-broadcast

A plugin for primus that adds a broadcast function to the socket/spark that excludes the the instance you're broadcasting from, the same way it works in socket.io.

If you are using the primus-emitter plugin as well, this will favor the .send() function over the .write() function. (You will have to pass this plugin to primus after you pass the primus-emitter one.)

var primusBroadcast = require('primus-broadcast');

primus.use('broadcast', primusBroadcast);

spark.on('data', function message(data) {
  // equivalent to socket.broadcast.emit() or socket.broadcast.send() in socket.io
  spark.broadcast('Received some data');
});

The implementation is very simple (look for yourself) but nice to have as a module.

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.0
    2
  • 1.0.0
    1

Package Sidebar

Install

npm i primus-broadcast

Weekly Downloads

3

Version

1.1.0

License

MIT

Last publish

Collaborators

  • fsbdev