rambler-digital-solutions/rship

View on GitHub
cli/commands/websocket/index.js

Summary

Maintainability
A
0 mins
Test Coverage
'use strict';

// ======================
// Depends
// ======================
const ws = require('nodejs-websocket');

/**
 * Create websocket server
 * @param {[type]} config [description]
 */
const WebsocketServer = function(config) {

  // config
  this.config = config || {
    host: 'localhost',
    port: '3002'
  };

  // prepapre websocket server
  this.server = ws.createServer(connection => {
    connection.on('error', err => {
      if (err.code !== 'ECONNRESET') {
        throw err
      }
    });
  }).listen(this.config.port);
};

module.exports = WebsocketServer;