Fix websocket path

This commit is contained in:
Christoph Hagen 2021-12-23 11:16:03 +01:00
parent 07d22e2de5
commit 15d2b3d670
2 changed files with 9 additions and 3 deletions

View File

@ -4,6 +4,11 @@
const apiPath = "/schafkopf"
function webSocketPath() {
const prefix = (window.location.protocol === "https:") ? "wss://" : "ws://"
return prefix + window.location.host + apiPath + "/session/start"
}
async function performRegisterPlayerRequest(name, password) {
return fetch(apiPath + "/player/register/" + name, { method: 'POST', body: password })
.then(convertServerResponse)

View File

@ -174,7 +174,8 @@ function leaveTable() {
}
function openSocket(token) {
socket = new WebSocket(((window.location.protocol === "https:") ? "wss://" : "ws://") + window.location.host + "/session/start")
const socketPath = webSocketPath()
socket = new WebSocket(socketPath)
socket.onopen = function(e) {
socket.send(token);