matchmaking support multigame

This commit is contained in:
2024-03-25 14:53:15 +01:00
parent 09e7476127
commit c232f03c17
5 changed files with 79 additions and 47 deletions

View File

@ -21,13 +21,12 @@ class MatchMaking
* @param {Number} mode The number of players in a game
* @returns {Promise<?>}
*/
async start(receive_func, disconnect_func, mode, gamemode)
async start(receive_func, disconnect_func, gamemode, mode)
{
if (!await this.client.isAuthenticated())
return null;
this.gamemode = gamemode
let url = `${window.location.protocol[4] === 's' ? 'wss' : 'ws'}://${window.location.host}/ws/matchmaking/${mode}`;
let url = `${window.location.protocol[4] === 's' ? 'wss' : 'ws'}://${window.location.host}/ws/matchmaking/${gamemode}/${mode}`;
this._socket = new WebSocket(url);
@ -50,10 +49,7 @@ class MatchMaking
this.disconnect_func(event);
}
/**
* @returns {Promise<?>}
*/
async stop()
stop()
{
if (this._socket)
this._socket.close();