mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
lint: src/node/handler/SocketIORouter.js
This commit is contained in:
parent
532bde71f7
commit
acf889b7de
1 changed files with 5 additions and 7 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue