How to use the primus.prototype function in primus

To help you get started, we’ve selected a few primus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cayasso / primus.io / lib / index.js View on Github external
function PrimusIO(server, options) {
  if (!(this instanceof PrimusIO)) return new PrimusIO(server, options);

  Primus.call(this, server, options);

  this
    .use('primus.io.js', library, this.indexOfLayer('primus.js'))
    .plugin('multiplex', 'primus-multiplex')
    .plugin('emitter', 'primus-emitter')
    .plugin('rooms', 'primus-rooms')
    .remove('primus.js');
}

// Inherits from `Primus` class.
PrimusIO.prototype.__proto__ = Primus.prototype;

// Copy over all static methods.
Object.keys(Primus).forEach(function each(ns) {
  var prop = Primus[ns];
  PrimusIO[ns] = 'function' !== typeof prop ? prop : prop.bind(Primus);
});

// Create socket.
PrimusIO.createSocket = function createSocket(options) {
  return (new PrimusIO(new Emitter(), options)).Socket;
};

primus

Primus is a simple abstraction around real-time frameworks. It allows you to easily switch between different frameworks without any code changes.

MIT
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis