omega-supreme-rooms-middleware

A middleware for omega-supreme that adds support for rooms. And automatically integrates it with metroplex if included


Keywords
primus, omega, supreme, primus-rooms, rooms, scaling, http, middleware
License
MIT
Install
npm install omega-supreme-rooms-middleware@1.1.6

Documentation

Omega Supreme Rooms Middleware

NPM version Build Status Dependencies Coverage Status

This middleware adds support for primus-rooms and automatically integrates it with metroplex if included. you MUST have primus-rooms installed.

Installation

npm install --save omega-supreme-rooms-middleware

Using the 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);

Messaging

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

Metroplex integration

The middleware automatically handles metroplex. If using metroplex and primus-rooms-redis-adapter.