forked from ppfun/pixelplanet
adjust timings of socket health check
This commit is contained in:
parent
bb89d6e55b
commit
09157955fa
|
@ -60,7 +60,7 @@ class SocketClient extends EventEmitter {
|
|||
checkHealth() {
|
||||
if (this.readyState === WebSocket.OPEN) {
|
||||
const now = Date.now();
|
||||
if (now - 20000 > this.timeLastPing) {
|
||||
if (now - 25000 > this.timeLastPing) {
|
||||
// server didn't send anything, probably dead
|
||||
console.log('Server is silent, killing websocket');
|
||||
this.readyState = WebSocket.CLOSING;
|
||||
|
@ -213,22 +213,16 @@ class SocketClient extends EventEmitter {
|
|||
const data = new DataView(buffer);
|
||||
const opcode = data.getUint8(0);
|
||||
|
||||
this.timeLastPing = Date.now();
|
||||
|
||||
switch (opcode) {
|
||||
case PixelUpdate.OP_CODE:
|
||||
this.emit('pixelUpdate', PixelUpdate.hydrate(data));
|
||||
break;
|
||||
case PixelReturn.OP_CODE:
|
||||
/*
|
||||
* using online counter and pxlReturn as sign-of-life ping
|
||||
*/
|
||||
this.timeLastPing = Date.now();
|
||||
this.emit('pixelReturn', PixelReturn.hydrate(data));
|
||||
break;
|
||||
case OnlineCounter.OP_CODE:
|
||||
/*
|
||||
* using online counter and pxlReturn as sign-of-life ping
|
||||
*/
|
||||
this.timeLastPing = Date.now();
|
||||
this.emit('onlineCounter', OnlineCounter.hydrate(data));
|
||||
break;
|
||||
case CoolDownPacket.OP_CODE:
|
||||
|
|
|
@ -348,7 +348,7 @@ class SocketServer {
|
|||
}
|
||||
|
||||
checkHealth() {
|
||||
const ts = Date.now() - 120 * 1000;
|
||||
const ts = Date.now() - 60 * 1000;
|
||||
this.wss.clients.forEach((ws) => {
|
||||
if (
|
||||
ws.readyState === WebSocket.OPEN
|
||||
|
|
BIN
utils/italy.png
Normal file
BIN
utils/italy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 MiB |
Loading…
Reference in New Issue
Block a user