summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWu Cheng-Han2016-07-05 16:11:18 +0800
committerWu Cheng-Han2016-07-05 16:11:18 +0800
commit40478f4effea55d9e83620aecb7878fc8b3a1ddf (patch)
tree0986b0cd47508e9998e6f3e5fc96499ff9d3ec53 /lib
parentf7a4f8f8c2ec5fb138e89f9f87309d784b41af8a (diff)
Fix realtime on finishConnection might not clear and connect next socket in queue and should use shift instead of pop on remove invalid socket in queue
Diffstat (limited to 'lib')
-rw-r--r--lib/realtime.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/realtime.js b/lib/realtime.js
index ad4ae215..25405338 100644
--- a/lib/realtime.js
+++ b/lib/realtime.js
@@ -323,17 +323,27 @@ function clearSocketQueue(queue, socket) {
}
}
+function connectNextSocket() {
+ isConnectionBusy = false;
+ if (connectionSocketQueue.length > 0)
+ startConnection(connectionSocketQueue[0]);
+}
+
var isConnectionBusy = false;
var connectionSocketQueue = [];
var isDisconnectBusy = false;
var disconnectSocketQueue = [];
function finishConnection(socket, note, user) {
+ // if no valid info provided will drop the client
if (!socket || !note || !user) {
if (note) delete note;
if (user) delete user;
- connectionSocketQueue.pop();
- isConnectionBusy = false;
+ if (socket)
+ clearSocketQueue(connectionSocketQueue, socket);
+ else
+ connectionSocketQueue.shift();
+ connectNextSocket();
return;
}
//check view permission
@@ -356,9 +366,7 @@ function finishConnection(socket, note, user) {
//clear finished socket in queue
clearSocketQueue(connectionSocketQueue, socket);
//seek for next socket
- isConnectionBusy = false;
- if (connectionSocketQueue.length > 0)
- startConnection(connectionSocketQueue[0]);
+ connectNextSocket();
if (config.debug) {
var noteId = socket.noteId;
@@ -436,7 +444,7 @@ function failConnection(code, err, socket) {
logger.error(err);
// clear error socket in queue
clearSocketQueue(connectionSocketQueue, socket);
- isConnectionBusy = false;
+ connectNextSocket();
// emit error info
socket.emit('info', {
code: code