From 342fa0cca30d6d9cea1855e3910f0ef3ef12fbeb Mon Sep 17 00:00:00 2001 From: Stefan Rupp Date: Fri, 11 Dec 2020 17:52:19 +0100 Subject: [PATCH] wip: game init by server --- templates/home/player.html | 5 +++++ templates/shared/_layout.html | 8 ++++---- views/player.py | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/templates/home/player.html b/templates/home/player.html index 2a171e3..d643943 100644 --- a/templates/home/player.html +++ b/templates/home/player.html @@ -27,6 +27,11 @@ let t = JSON.stringify(msg); window.game_socket.send(t); } + + function setupGame(player_names) { + + } +
diff --git a/templates/shared/_layout.html b/templates/shared/_layout.html index 91710b4..2c64aa7 100644 --- a/templates/shared/_layout.html +++ b/templates/shared/_layout.html @@ -47,6 +47,7 @@ else if (fct == "startGame") { let names = msg.names setupGame(names) + alert('game is set up') } else { alert('unknown command: '+event.data); @@ -55,11 +56,10 @@ socket.onclose = function(event) { if (event.wasClean) { - //alert(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`); + alert(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`); + //alert('closed clean'); } else { - // e.g. server process killed or network down - // event.code is usually 1006 in this case - //alert('[close] Connection died'); + //alert('closed unclean'); } }; diff --git a/views/player.py b/views/player.py index 845347a..74cc1e8 100644 --- a/views/player.py +++ b/views/player.py @@ -96,7 +96,9 @@ async def websocket(ws): color = x['color'] await set_trump_color(player, color) elif fct == "requestInit": + print("before init") await initGame(ws); + print("after init") else: print("confused :(")