Commit dd33c5b5 authored by Sebastien Cante's avatar Sebastien Cante Committed by Wandenberg Peixoto

Added a End of batch flag for client of pushtream.js to know when it is...

Added a End of batch flag for client of pushtream.js to know when it is finished receiving a long polling batch. End of batch flag is set to true for all transport except long polling  when the client can receive a batch of messages at once in between 2 long polling request. This is to help client pushstream.js to implement some filter logic at batch level (for example discard stale messages)
parent 94331348
...@@ -359,7 +359,7 @@ ...@@ -359,7 +359,7 @@
var onmessageCallback = function(event) { var onmessageCallback = function(event) {
Log4js.info("[" + this.type + "] message received", arguments); Log4js.info("[" + this.type + "] message received", arguments);
var message = parseMessage(event.data, this.pushstream); var message = parseMessage(event.data, this.pushstream);
this.pushstream._onmessage(message.data, message.id, message.channel, message.eventid); this.pushstream._onmessage(message.data, message.id, message.channel, message.eventid, true);
}; };
var onopenCallback = function() { var onopenCallback = function() {
...@@ -547,7 +547,7 @@ ...@@ -547,7 +547,7 @@
process: function(id, channel, data, eventid) { process: function(id, channel, data, eventid) {
this.pingtimer = clearTimer(this.pingtimer); this.pingtimer = clearTimer(this.pingtimer);
Log4js.info("[Stream] message received", arguments); Log4js.info("[Stream] message received", arguments);
this.pushstream._onmessage(unescapeText(data), id, channel, eventid); this.pushstream._onmessage(unescapeText(data), id, channel, eventid, true);
this.setPingTimer(); this.setPingTimer();
}, },
...@@ -704,7 +704,7 @@ ...@@ -704,7 +704,7 @@
while (this.messagesQueue.length > 0) { while (this.messagesQueue.length > 0) {
var message = this.messagesQueue.shift(); var message = this.messagesQueue.shift();
this.pushstream._onmessage(message.data, message.id, message.channel, message.eventid); this.pushstream._onmessage(message.data, message.id, message.channel, message.eventid, (this.messagesQueue.length === 0));
} }
} }
}; };
...@@ -888,12 +888,12 @@ ...@@ -888,12 +888,12 @@
this._reconnect(this.reconnecttimeout); this._reconnect(this.reconnecttimeout);
}, },
_onmessage: function(data, id, channel, eventid) { _onmessage: function(data, id, channel, eventid, isLastMessageFromBatch) {
Log4js.debug("message", data, id, channel, eventid); Log4js.debug("message", data, id, channel, eventid, isLastMessageFromBatch);
if (id == -2) { if (id == -2) {
if (this.onchanneldeleted) { this.onchanneldeleted(channel); } if (this.onchanneldeleted) { this.onchanneldeleted(channel); }
} else if ((id > 0) && (typeof(this.channels[channel]) !== "undefined")) { } else if ((id > 0) && (typeof(this.channels[channel]) !== "undefined")) {
if (this.onmessage) { this.onmessage(data, id, channel, eventid); } if (this.onmessage) { this.onmessage(data, id, channel, eventid, isLastMessageFromBatch); }
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment