action hero broadcaster plugin
npm install ah-broadcaster-pluginah-broadcaster-plugin
=====================
Helps broadcasting a message to every client connection in a channel. Most important difference from chat, it doesn't let clients broadcast anything to anyone.
sh
npm install ah-broadcaster-plugin --save
`
Don't forget to enable plugin in action hero config (config/api.js).How to use
There are three methods in this plugin: join, leave and broadcast.
$3
You can add any connection to a channel by id anytime you need.
`js
api.channel.join(connection.id, 'my_channel');
`$3
You can remove any connection from a channel by id anytime you need.
`js
api.channel.leave(connection.id, 'my_channel');
`$3
You can broadcast any message to a channel using this method.
`js
api.channel.broadcast('my_channel', {message: 'hello'});
`
Try sending your message to channel "all" for boradcasting every client:
`js
api.channel.broadcast('all', {message: 'hello'});
``