From 5dd29f1fe7e41c6ffd84f32627d309f62747aa81 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 11 Jan 2021 15:13:48 -0600 Subject: [PATCH] channel.js: ack every 30 events *even if this.outstandingJSON is empty* --- pkg/arvo/app/landscape/js/channel.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/arvo/app/landscape/js/channel.js b/pkg/arvo/app/landscape/js/channel.js index 2f10d6bc6c..a85fda9ba9 100644 --- a/pkg/arvo/app/landscape/js/channel.js +++ b/pkg/arvo/app/landscape/js/channel.js @@ -182,19 +182,19 @@ class Channel { // sends a JSON command command to the server. // sendJSONToChannel(j) { - if(!j && this.outstandingJSON.length === 0) { - return; - } let req = new XMLHttpRequest(); req.open("PUT", this.channelURL()); req.setRequestHeader("Content-Type", "application/json"); if (this.lastEventId == this.lastAcknowledgedEventId) { - if(j) { + if (j) { this.outstandingJSON.push(j); } - let x = JSON.stringify(this.outstandingJSON); - req.send(x); + + if (this.outstandingJSON.length > 0) { + let x = JSON.stringify(this.outstandingJSON); + req.send(x); + } } else { // we add an acknowledgment to clear the server side queue // @@ -205,7 +205,7 @@ class Channel { ...this.outstandingJSON, {action: "ack", "event-id": parseInt(this.lastEventId)} ]; - if(j) { + if (j) { payload.push(j) } let x = JSON.stringify(payload);