Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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.
//