diff --git a/templates/shared/_layout.html b/templates/shared/_layout.html index c9935a3..6e57a62 100644 --- a/templates/shared/_layout.html +++ b/templates/shared/_layout.html @@ -34,10 +34,13 @@ socket.onmessage = function(event) { //alert(`[message] Data received from server: ${event.data}`); - if (event.data == "reload") { + //if (event.data == "reload") { + let x = JSON.parse(event.data); + let fct = x.fct; + if (fct == "reload") { location.reload(true); } - else if (event.data.startsWith("start game: ")) { + else if (fct == "startGame") { let names = "..." } else { diff --git a/views/player.py b/views/player.py index 2e0c864..5437e87 100644 --- a/views/player.py +++ b/views/player.py @@ -76,15 +76,12 @@ async def websocket(ws): the_game.websockets.append(ws) try: x = await ws.receive_json() - print(x) fct = x['fct'] if fct == 'playcard': - print("play card :)") p = int(x['player']) c = int(x['card']) await play_card(p, c) elif fct == 'setTrumpColor': - print("trump color :)") player = x['player'] color = x['color'] await set_trump_color(player, color) diff --git a/wiz_game.py b/wiz_game.py index f853477..2e1f1d0 100644 --- a/wiz_game.py +++ b/wiz_game.py @@ -1,4 +1,3 @@ - import random from operator import attrgetter @@ -215,7 +214,8 @@ class WizGame: async def send_page_reload(self): for ws in self.websockets: try: - await ws.send_text("reload") + msg = {"type": "message", "fct": "reload"}; + await ws.send_json(msg) except Exception as e: pass