How to use the sockjs.Server function in sockjs

To help you get started, we’ve selected a few sockjs 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 aaronblohowiak / Push-It / server / push-it.js View on Github external
var PushIt = function (server, options) {
  EventEmitter.apply(this, arguments);

  if(options.help) help();

  this.server = server;
  
  if (options.socket){
    this.sock = options.socket;
  }else{
    var sockjs_opts = {sockjs_url: "http://majek.github.com/sockjs-client/sockjs-latest.min.js"};
    var sjs_echo = new sjs.Server(sockjs_opts);
    sjs_echo.installHandlers(this.server, {prefix:'[/]pi/'});
    this.sock = sjs_echo;
  }

  var self = this;
  this.sock.on('open', function (client) {
    self.emit('connection', client);
  });
  if (!options.skipSetupIO) this.setupIO();
  
  this.mq = options.mq || new InMemoryMQ();

  this.channels = options.channels || {};
  this.subscriptionManager = options.subscriptionManager || new SubscriptionManager(this.mq);
};

sockjs

SockJS-node is a server counterpart of SockJS-client a JavaScript library that provides a WebSocket-like object in the browser. SockJS gives you a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication

MIT
Latest version published 3 years ago

Package Health Score

76 / 100
Full package analysis