}
}
- function stopConnection() {
+ function closeConnections() {
if (eventSource) {
eventSource.onerror = null;
eventSource.close();
webSocket.close();
webSocket = null;
}
+ }
+
+ function stopConnection() {
+ closeConnections();
if (retryPollingTimeout) {
clearTimeout(retryPollingTimeout);
function pollServerWithEventSource() {
if (ENABLE_EVENT_SOURCE && window.EventSource) {
+ closeConnections();
eventSource = new EventSource("/:trivabble/sse/" + JSON.stringify(cmdsWithContext()));
bindConnectionEvents(eventSource);
return;
function pollServerWithWebSocket() {
if (ENABLE_WEBSOCKETS && !blacklistWebsockets && window.WebSocket) {
+ closeConnections();
webSocket = new WebSocket(
(window.location.protocol === "http:" ? "ws://" : "wss://") +
window.location.host +