lint: src/node/handler/SocketIORouter.js

pull/4667/head
John McLear 2021-01-21 21:06:52 +00:00 committed by Richard Hansen
parent 532bde71f7
commit acf889b7de
1 changed files with 5 additions and 7 deletions

View File

@ -1,3 +1,4 @@
'use strict';
/**
* 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
@ -21,9 +22,6 @@
const log4js = require('log4js');
const messageLogger = log4js.getLogger('message');
const securityManager = require('../db/SecurityManager');
const readOnlyManager = require('../db/ReadOnlyManager');
const settings = require('../utils/Settings');
/**
* Saves all components
@ -37,7 +35,7 @@ let socket;
/**
* adds a component
*/
exports.addComponent = function (moduleName, module) {
exports.addComponent = (moduleName, module) => {
// save the component
components[moduleName] = module;
@ -48,14 +46,14 @@ exports.addComponent = function (moduleName, module) {
/**
* sets the socket.io and adds event functions for routing
*/
exports.setSocketIO = function (_socket) {
exports.setSocketIO = (_socket) => {
// save this socket internaly
socket = _socket;
socket.sockets.on('connection', (client) => {
// wrap the original send function to log the messages
client._send = client.send;
client.send = function (message) {
client.send = (message) => {
messageLogger.debug(`to ${client.id}: ${JSON.stringify(message)}`);
client._send(message);
};
@ -66,7 +64,7 @@ exports.setSocketIO = function (_socket) {
}
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)}`);
return;
}