From 104cf313b8c4332eb7b2381a37544c1925a9cd34 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jul 2015 21:41:56 +0300 Subject: [PATCH 1/4] the connection used to only read a single chunk of data when it new data is recived, so that if a buffer larger the a single operation is recived it will cause all updates to lag, this couses issues for the live query since it often recives an update for each registeration on the same connecion, changed it to parse the entire buffer til its end but only one chunk at a time --- lib/transport/binary/connection.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/transport/binary/connection.js b/lib/transport/binary/connection.js index 86ea9493..2de71996 100644 --- a/lib/transport/binary/connection.js +++ b/lib/transport/binary/connection.js @@ -283,6 +283,8 @@ Connection.prototype.handleSocketData = function (data) { this.remaining = null; } else { + this.handleSocketData(buffer.slice(offset)); + this.remaining = buffer.slice(offset); } }; @@ -365,7 +367,7 @@ Connection.prototype.process = function (buffer, offset) { result = parsed[2]; this.emit('update-config', result); return offset; - }else if(status === OperationStatus.LIVE_RESULT){ + } else if (status === OperationStatus.LIVE_RESULT){ token = parsed[1]; operation = parsed[2]; result = parsed[3]; @@ -412,4 +414,4 @@ Connection.prototype.process = function (buffer, offset) { } } return offset; -}; +}; \ No newline at end of file From 91f77c613f50b789b2416349242e9b0117e96ad1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jul 2015 21:58:56 +0300 Subject: [PATCH 2/4] remove redundente remaing --- lib/transport/binary/connection.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/transport/binary/connection.js b/lib/transport/binary/connection.js index 2de71996..c9d42013 100644 --- a/lib/transport/binary/connection.js +++ b/lib/transport/binary/connection.js @@ -284,9 +284,7 @@ Connection.prototype.handleSocketData = function (data) { } else { this.handleSocketData(buffer.slice(offset)); - - this.remaining = buffer.slice(offset); - } + } }; /** From 9c391d0125ab75ca8e48797b0244e84dfaaf98d3 Mon Sep 17 00:00:00 2001 From: imdark Date: Wed, 22 Jul 2015 22:49:56 +0300 Subject: [PATCH 3/4] changed connection data processing reading to be at zero interval to allow for context switching to not take too much time on the main js thread --- lib/transport/binary/connection.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/transport/binary/connection.js b/lib/transport/binary/connection.js index c9d42013..b73dbedc 100644 --- a/lib/transport/binary/connection.js +++ b/lib/transport/binary/connection.js @@ -283,7 +283,10 @@ Connection.prototype.handleSocketData = function (data) { this.remaining = null; } else { - this.handleSocketData(buffer.slice(offset)); + var self = this; + setTimeout(function() { + self.handleSocketData(buffer.slice(offset)) + }); } }; From 20d0d730dd59e8c929d5e6c8d5b5a54fd3d6b0b6 Mon Sep 17 00:00:00 2001 From: imdark Date: Wed, 22 Jul 2015 22:59:57 +0300 Subject: [PATCH 4/4] added semicolumn --- lib/transport/binary/connection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/transport/binary/connection.js b/lib/transport/binary/connection.js index b73dbedc..87cf65bd 100644 --- a/lib/transport/binary/connection.js +++ b/lib/transport/binary/connection.js @@ -285,7 +285,7 @@ Connection.prototype.handleSocketData = function (data) { else { var self = this; setTimeout(function() { - self.handleSocketData(buffer.slice(offset)) + self.handleSocketData(buffer.slice(offset)); }); } };