(function () {
"use strict";
- const VERSION = 202004222300;
+ const VERSION = 202004262313;
const Conf = window.TrivabbleConf || {};
setConf("ENABLE_WEBSOCKETS", true);
setConf("ENABLE_EVENT_SOURCE", true);
setConf("MAX_WEBSOCKET_ERRORS", 1);
+ setConf("APP_PATH", "");
const _ = (window.libD && libD.l10n) ? libD.l10n() : function (s) {return s;};
let pollingServer = false;
let connectionStopped = false;
+ // HTTP path url prefix for any socket (xhr,ess or ws) from browser to server access
+ function getApiEntryPoint() {
+ return Conf.APP_PATH + "/:trivabble";
+ }
+
function mouseDown(ele, fun, stop) {
const meth = stop ? "removeEventListener" : "addEventListener";
ele[meth]("mousedown", fun, false);
closeConnections();
pollingServer = true;
- eventSource = new EventSource("/:trivabble/sse/" + JSON.stringify(cmdsWithContext()));
+ eventSource = new EventSource(getApiEntryPoint() + "/sse/" + JSON.stringify(cmdsWithContext()));
bindConnectionEvents(eventSource);
return;
}
webSocket = new WebSocket(
(window.location.protocol === "http:" ? "ws://" : "wss://") +
window.location.host +
- "/:trivabble/ws/" +
+ getApiEntryPoint() + "/ws/" +
JSON.stringify(cmdsWithContext())
);
function xhrRequest(data, onreadystatechange) {
const xhr = new XMLHttpRequest();
- xhr.open("POST", "/:trivabble", true);
+ xhr.open("POST", getApiEntryPoint(), true);
xhr.setRequestHeader("Content-Type", "text/plain");
xhr.send(JSON.stringify(data));