summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWu Cheng-Han2016-10-14 17:36:04 +0800
committerWu Cheng-Han2016-10-14 17:36:04 +0800
commit1418b7a801ee19d8b45201c844c86366f988c5d4 (patch)
treeef7bfd6e42f14bc5e44cf53209f4cdaa50a1976a
parent211d25253ec6f5a067affae77308007224b5f33d (diff)
Fix socket disconnect might interrupt loop issue
Diffstat (limited to '')
-rw-r--r--lib/realtime.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/realtime.js b/lib/realtime.js
index d069a486..b50e05b2 100644
--- a/lib/realtime.js
+++ b/lib/realtime.js
@@ -97,7 +97,9 @@ var updater = setInterval(function () {
for (var i = 0, l = note.socks.length; i < l; i++) {
var sock = note.socks[i];
if (typeof sock !== 'undefined' && sock) {
- sock.disconnect(true);
+ setTimeout(function () {
+ sock.disconnect(true);
+ }, 0);
}
}
return callback(err, null);
@@ -787,7 +789,9 @@ function connection(socket) {
sock.emit('info', {
code: 403
});
- return sock.disconnect(true);
+ setTimeout(function () {
+ sock.disconnect(true);
+ }, 0);
}
}
}
@@ -818,7 +822,9 @@ function connection(socket) {
var sock = note.socks[i];
if (typeof sock !== 'undefined' && sock) {
sock.emit('delete');
- return sock.disconnect(true);
+ setTimeout(function () {
+ sock.disconnect(true);
+ }, 0);
}
}
}).catch(function (err) {