lint: src/node/handler/SocketIORouter.js

This commit is contained in:
John McLear 2021-01-21 21:06:52 +00:00 committed by Richard Hansen
parent 532bde71f7
commit acf889b7de

View file

@ -1,3 +1,4 @@
'use strict';
/** /**
* This is the Socket.IO Router. It routes the Messages between the * This is the Socket.IO Router. It routes the Messages between the
* components of the Server. The components are at the moment: pad and timeslider * components of the Server. The components are at the moment: pad and timeslider
@ -21,9 +22,6 @@
const log4js = require('log4js'); const log4js = require('log4js');
const messageLogger = log4js.getLogger('message'); const messageLogger = log4js.getLogger('message');
const securityManager = require('../db/SecurityManager');
const readOnlyManager = require('../db/ReadOnlyManager');
const settings = require('../utils/Settings');
/** /**
* Saves all components * Saves all components
@ -37,7 +35,7 @@ let socket;
/** /**
* adds a component * adds a component
*/ */
exports.addComponent = function (moduleName, module) { exports.addComponent = (moduleName, module) => {
// save the component // save the component
components[moduleName] = module; components[moduleName] = module;
@ -48,14 +46,14 @@ exports.addComponent = function (moduleName, module) {
/** /**
* sets the socket.io and adds event functions for routing * sets the socket.io and adds event functions for routing
*/ */
exports.setSocketIO = function (_socket) { exports.setSocketIO = (_socket) => {
// save this socket internaly // save this socket internaly
socket = _socket; socket = _socket;
socket.sockets.on('connection', (client) => { socket.sockets.on('connection', (client) => {
// wrap the original send function to log the messages // wrap the original send function to log the messages
client._send = client.send; client._send = client.send;
client.send = function (message) { client.send = (message) => {
messageLogger.debug(`to ${client.id}: ${JSON.stringify(message)}`); messageLogger.debug(`to ${client.id}: ${JSON.stringify(message)}`);
client._send(message); client._send(message);
}; };
@ -66,7 +64,7 @@ exports.setSocketIO = function (_socket) {
} }
client.on('message', async (message) => { client.on('message', async (message) => {
if (message.protocolVersion && message.protocolVersion != 2) { if (message.protocolVersion && message.protocolVersion !== 2) {
messageLogger.warn(`Protocolversion header is not correct: ${JSON.stringify(message)}`); messageLogger.warn(`Protocolversion header is not correct: ${JSON.stringify(message)}`);
return; return;
} }