Merge tag 'v2.9.2' into instance_only_statuses

This commit is contained in:
Renato "Lond" Cerqueira
2019-06-25 19:44:59 +02:00
534 changed files with 12629 additions and 7877 deletions

View File

@ -7,7 +7,7 @@ const redis = require('redis');
const pg = require('pg');
const log = require('npmlog');
const url = require('url');
const WebSocket = require('uws');
const { WebSocketServer } = require('@clusterws/cws');
const uuid = require('uuid');
const fs = require('fs');
@ -578,20 +578,13 @@ const startWorker = (workerId) => {
});
});
const wss = new WebSocket.Server({ server, verifyClient: wsVerifyClient });
const wss = new WebSocketServer({ server, verifyClient: wsVerifyClient });
wss.on('connection', ws => {
const req = ws.upgradeReq;
wss.on('connection', (ws, req) => {
const location = url.parse(req.url, true);
req.requestId = uuid.v4();
req.remoteAddress = ws._socket.remoteAddress;
ws.isAlive = true;
ws.on('pong', () => {
ws.isAlive = true;
});
let channel;
switch(location.query.stream) {
@ -652,17 +645,7 @@ const startWorker = (workerId) => {
}
});
setInterval(() => {
wss.clients.forEach(ws => {
if (ws.isAlive === false) {
ws.terminate();
return;
}
ws.isAlive = false;
ws.ping('', false, true);
});
}, 30000);
wss.startAutoPing(30000);
attachServerWithConfig(server, address => {
log.info(`Worker ${workerId} now listening on ${address}`);