How to use lws - 1 common examples

To help you get started, we’ve selected a few lws 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 primus / primus / transformers / lws / server.js View on Github external
module.exports = function server() {
  var WebSocketServer = require('lws').Server
    , Spark = this.Spark;

  var service = this.service = new WebSocketServer({
    perMessageDeflate: !!this.primus.options.compression
  });

  service.on('message', function (socket, message, binary) {
    var spark = service.getUserData(socket);
    spark.emit('incoming::data', binary ? message : message.toString());
  });

  service.on('close', function (socket) {
    var spark = service.getUserData(socket);
    spark.emit('incoming::end');
  });

  //
  // Listen to upgrade requests.
  //

lws

A lean, modular web server for rapid full-stack development

MIT
Latest version published 4 months ago

Package Health Score

64 / 100
Full package analysis

Popular lws functions