Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

egg-ez-ws

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-ez-ws - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

2

lib/ClientManager/index.d.ts

@@ -0,1 +1,2 @@

/// <reference types="node" />
import { BaseManager } from '../common/BaseManager';

@@ -14,2 +15,3 @@ import * as WebSocket from 'ws';

readonly logger: import("_egg-logger@2.4.1@egg-logger").EggLogger;
readonly checkHeart: NodeJS.Timeout;
private commandProcessors;

@@ -16,0 +18,0 @@ private clients;

24

lib/ClientManager/index.js

@@ -17,2 +17,10 @@ "use strict";

this.logger = this.app.getLogger('ClientManager');
this.checkHeart = setInterval(() => {
[...this.clients.values()].forEach(client => client.ws.ping('', undefined, err => {
if (err) {
this.logger.warn(client.id, 'ping fail!', err);
client.ws.close();
}
}));
}, 30 * 1000);
this.commandProcessors = [];

@@ -40,17 +48,2 @@ this.clients = new Map();

this.onClientConnect.emit(client);
let failCount = 0;
const pingTimer = setInterval(() => {
ws.ping('', undefined, err => {
if (err) {
failCount++;
this.logger.warn(client.id, 'ping fail!', failCount, err);
if (failCount >= 2) {
ws.close();
}
}
else {
failCount = 0;
}
});
}, 30 * 1000);
ws.onmessage = evt => {

@@ -90,3 +83,2 @@ if (!evt || evt.type !== 'message') {

this.logger.info('[client] onclose', client.id);
clearInterval(pingTimer);
this.clients.delete(client.id);

@@ -93,0 +85,0 @@ const clientInfo = yield this.broadcast(new W_A_1.ClientDisconnectEvent({ id: client.id }), A_W_1.ClientInfoResponseEvent);

{
"name": "egg-ez-ws",
"version": "0.1.9",
"version": "0.1.10",
"description": "easy websocket for egg.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc