fix: go to url when game found
This commit is contained in:
parent
8529963f97
commit
39ea33cc8e
@ -19,7 +19,7 @@ export default class extends AbstractAuthentifiedView {
|
|||||||
{
|
{
|
||||||
let nb_players = document.getElementById("nb_players-input").value
|
let nb_players = document.getElementById("nb_players-input").value
|
||||||
|
|
||||||
await client.matchmaking.start(this.display_data, this.ondisconnect, nb_players);
|
await client.matchmaking.start(this.onreceive.bind(this), this.ondisconnect.bind(this), nb_players);
|
||||||
|
|
||||||
document.getElementById("button").value = "Stop matchmaking"
|
document.getElementById("button").value = "Stop matchmaking"
|
||||||
}
|
}
|
||||||
@ -30,6 +30,16 @@ export default class extends AbstractAuthentifiedView {
|
|||||||
document.getElementById("button").value = "Find a game"
|
document.getElementById("button").value = "Find a game"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onreceive(data)
|
||||||
|
{
|
||||||
|
if (data.detail === "game_found")
|
||||||
|
{
|
||||||
|
navigateTo(`/games/${data.game_id}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.display_data(data)
|
||||||
|
}
|
||||||
|
|
||||||
display_data(data)
|
display_data(data)
|
||||||
{
|
{
|
||||||
clear("innerText", ["detail"]);
|
clear("innerText", ["detail"]);
|
||||||
|
@ -32,7 +32,7 @@ class MatchMaking(WebsocketConsumer):
|
|||||||
print(len(waiting_room), "/", self.mode, [len(waiting_room),self.mode])
|
print(len(waiting_room), "/", self.mode, [len(waiting_room),self.mode])
|
||||||
if (len(waiting_room) == self.mode):
|
if (len(waiting_room) == self.mode):
|
||||||
game_id: int = GameModel().create(waiting_room.get_users_id())
|
game_id: int = GameModel().create(waiting_room.get_users_id())
|
||||||
waiting_room.broadcast({"detail": "Game found !", "game_id": game_id})
|
waiting_room.broadcast("game_found", {"game_id": game_id})
|
||||||
waiting_room.clear()
|
waiting_room.clear()
|
||||||
|
|
||||||
def disconnect(self, close_code):
|
def disconnect(self, close_code):
|
||||||
|
Loading…
Reference in New Issue
Block a user