This middleware adds support for primus-rooms
and automatically integrates it with metroplex
if included.
you MUST have primus-rooms
installed.
npm install --save omega-supreme-rooms-middleware
Just set the middleware in primus options so omega-primus can use it, see example below:
'use strict';
var Primus = require('primus')
, server = require('http').createServer()
, middleware = require('omega-supreme-rooms-middleware');
var primus = new Primus(server, {
/* Add the options here, in the Primus's options */
});
primus.plugin('omega-supreme', require('omega-supreme'));
primus.options.middleware = middleware();
server.listen(8080);
The middleware follows and maintains all functionality of omega-supreme
.
The middleware adds the ability to make requests with the following properties:
- The
rooms
property can be an array or a string of room names. Message will be broadcasted to all the sparks connected to the rooms. - The
except
property can be an array or a string of spark ids. Message will not be broadcasted to the sparks in the except property. This property will only be used when rooms property is provided
The middleware automatically handles metroplex. If using metroplex and primus-rooms-redis-adapter
.