fix: websocket url

This commit is contained in:
starnakin 2023-12-26 14:28:04 +01:00
parent 52c7d9eafb
commit efbcd10fb0
3 changed files with 6 additions and 18 deletions

View File

@ -14,12 +14,7 @@ class Channel {
// reload = function to use when we receive a message
async connect(reload) {
let url = `
${window.location.protocol == 'https' ? 'wss' : 'ws'}
://${window.location.host}
/ws/chat/
${this.channel_id}/
`;
let url = `${window.location.protocol[4] === 's' ? 'wss' : 'ws'}://${window.location.host}/ws/chat/${this.channel_id}`;
this.chatSocket = new WebSocket(url);
this.chatSocket.onmessage = (event) =>{

View File

@ -19,12 +19,7 @@ class MatchMaking
if (!await this.client.isAuthentificate())
return null;
let url = `
${window.location.protocol == 'https' ? 'wss' : 'ws'}
://${window.location.host}
/ws/matchmaking/
${mode}
`;
let url = `${window.location.protocol[4] === 's' ? 'wss' : 'ws'}://${window.location.host}/ws/matchmaking/${mode}`;
this._socket = new WebSocket(url);

View File

@ -77,13 +77,11 @@ class Tourmanent
if (!await this.client.isAuthentificate())
return null;
let url = `
${window.location.protocol == 'https' ? 'wss' : 'ws'}
://${window.location.host}
/ws/tournaments/
${this.id}
`;
console.log(window.location.protocol);
let url = `${window.location.protocol[4] === 's' ? 'wss' : 'ws'}://${window.location.host}/ws/tournaments/${this.id}`;
console.log(url);
this._socket = new WebSocket(url);
this.connected = true;