Skip to content

Commit 650a18d

Browse files
committed
fix(webeditor): keep collecting queued requests even while the channel is live
1 parent 6d2866f commit 650a18d

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

src/main/java/net/blueva/menu/webeditor/WebEditorManager.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -159,37 +159,29 @@ private void startRealtime(JsonObject heartbeat) {
159159
}
160160

161161
/**
162-
* Switches between the channel and polling, and tells the editor at once so
163-
* it stops publishing requests nobody is listening for.
162+
* Records whether the channel is delivering and tells the editor at once.
163+
*
164+
* The HTTP poll keeps running either way. A request is published to the
165+
* channel or left in the queue, never both, so collecting the queue costs
166+
* one small request a second and catches anything the channel could not
167+
* carry, such as a publish endpoint that is not routed.
164168
*/
165169
private synchronized void onRealtimeState(boolean carryingTraffic) {
166170
if (carryingTraffic == !polling) {
167171
return;
168172
}
169173

170174
polling = !carryingTraffic;
171-
172-
if (polling) {
173-
logger.warning("The web editor channel is not delivering, falling back to polling");
174-
startPolling();
175-
} else {
176-
logger.info("The web editor channel is live, stopping the HTTP poll");
177-
stopPolling();
178-
}
175+
logger.info(polling
176+
? "The web editor channel is not delivering, requests will come over HTTP"
177+
: "The web editor channel is live");
179178

180179
api.heartbeat(polling).exceptionally(error -> {
181180
logger.fine("Heartbeat failed: " + rootMessage(error));
182181
return null;
183182
});
184183
}
185184

186-
private synchronized void stopPolling() {
187-
if (pollTask != null) {
188-
pollTask.cancel();
189-
pollTask = null;
190-
}
191-
}
192-
193185
private void startHeartbeat() {
194186
heartbeatTask = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin,
195187
() -> api.heartbeat(polling).exceptionally(error -> {

0 commit comments

Comments
 (0)