lint: Run eslint --fix on src/

This commit is contained in:
Richard Hansen 2020-11-23 13:24:19 -05:00 committed by John McLear
parent b8d07a42eb
commit 8e5fd19db2
109 changed files with 9061 additions and 10572 deletions

View file

@ -19,53 +19,53 @@
* limitations under the License.
*/
var log4js = require('log4js');
var messageLogger = log4js.getLogger("message");
var securityManager = require("../db/SecurityManager");
var readOnlyManager = require("../db/ReadOnlyManager");
var settings = require('../utils/Settings');
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
* key is the component name
* value is the component module
*/
var components = {};
const components = {};
var socket;
let socket;
/**
* adds a component
*/
exports.addComponent = function(moduleName, module) {
exports.addComponent = function (moduleName, module) {
// save the component
components[moduleName] = module;
// give the module the socket
module.setSocketIO(socket);
}
};
/**
* sets the socket.io and adds event functions for routing
*/
exports.setSocketIO = function(_socket) {
exports.setSocketIO = function (_socket) {
// save this socket internaly
socket = _socket;
socket.sockets.on('connection', function(client) {
socket.sockets.on('connection', (client) => {
// wrap the original send function to log the messages
client._send = client.send;
client.send = function(message) {
client.send = function (message) {
messageLogger.debug(`to ${client.id}: ${JSON.stringify(message)}`);
client._send(message);
}
};
// tell all components about this connect
for (let i in components) {
for (const i in components) {
components[i].handleConnect(client);
}
client.on('message', async function(message) {
client.on('message', async (message) => {
if (message.protocolVersion && message.protocolVersion != 2) {
messageLogger.warn(`Protocolversion header is not correct: ${JSON.stringify(message)}`);
return;
@ -78,11 +78,11 @@ exports.setSocketIO = function(_socket) {
await components[message.component].handleMessage(client, message);
});
client.on('disconnect', function() {
client.on('disconnect', () => {
// tell all components about this disconnect
for (let i in components) {
for (const i in components) {
components[i].handleDisconnect(client);
}
});
});
}
};