chainpad-server
Advanced tools
Comparing version 4.0.5 to 4.0.6
@@ -130,2 +130,3 @@ /* jshint esversion: 6 */ | ||
const dropUser = function (ctx, user, reason) { | ||
if (!user || !user.socket) { return; } | ||
if (user.socket.readyState !== WEBSOCKET_CLOSING | ||
@@ -315,9 +316,13 @@ && user.socket.readyState !== WEBSOCKET_CLOSED) | ||
let u = ctx.users[userId]; | ||
if (time - u.timeOfLastMessage > LAG_MAX_BEFORE_DISCONNECT) { | ||
ctx.dropUser(u, "INACTIVITY"); | ||
try { | ||
if (time - u.timeOfLastMessage > LAG_MAX_BEFORE_DISCONNECT) { | ||
ctx.dropUser(u, "INACTIVITY"); | ||
} | ||
if (!u.pingOutstanding && time - u.timeOfLastMessage > LAG_MAX_BEFORE_PING) { | ||
sendMsg(ctx, u, [0, '', 'PING', now()]); | ||
u.pingOutstanding = true; | ||
} | ||
} catch (err) { | ||
ctx.emit.error(err, 'USER_ACTIVITY_CHECK'); | ||
} | ||
if (!u.pingOutstanding && time - u.timeOfLastMessage > LAG_MAX_BEFORE_PING) { | ||
sendMsg(ctx, u, [0, '', 'PING', now()]); | ||
u.pingOutstanding = true; | ||
} | ||
}); | ||
@@ -473,4 +478,4 @@ }; | ||
ctx.dropUser = function (user, reason) { | ||
dropUser(ctx, user, reason); | ||
ctx.dropUser = function (userId, reason) { | ||
dropUser(ctx, ctx.users[userId], reason); | ||
}; | ||
@@ -477,0 +482,0 @@ |
{ | ||
"name": "chainpad-server", | ||
"description": "api backend for realtime collaborative visual editor with zero knowlege server", | ||
"version": "4.0.5", | ||
"version": "4.0.6", | ||
"dependencies": { | ||
@@ -6,0 +6,0 @@ "nthen": "0.1.8", |
18054
460