fix(api): Fixed websocket routing (#88)
Reviewed-on: #88 Co-authored-by: Janis <janis.e.20@gmx.de> Co-committed-by: Janis <janis.e.20@gmx.de>
This commit is contained in:
@@ -91,7 +91,12 @@ function setupSocketHandlers(socket) {
|
||||
}
|
||||
|
||||
// connect/disconnect helpers
|
||||
function connectWebSocket(url = "ws://localhost:9000/websocket") {
|
||||
function connectWebSocket(url = null) {
|
||||
if (!url) {
|
||||
const loc = window.location;
|
||||
const protocol = loc.protocol === "https:" ? "wss:" : "ws:";
|
||||
url = protocol + "//" + loc.host + "/websocket";
|
||||
}
|
||||
if (ws && ws.readyState === WebSocket.OPEN) return Promise.resolve();
|
||||
if (ws && ws.readyState === WebSocket.CONNECTING) {
|
||||
// already connecting - return a promise that resolves on open
|
||||
|
||||
Reference in New Issue
Block a user