wip: game init by server

This commit is contained in:
Stefan Rupp 2020-12-11 17:52:19 +01:00
parent bcfc488c2e
commit 342fa0cca3
3 changed files with 11 additions and 4 deletions

View File

@ -27,6 +27,11 @@
let t = JSON.stringify(msg); let t = JSON.stringify(msg);
window.game_socket.send(t); window.game_socket.send(t);
} }
function setupGame(player_names) {
}
</script> </script>
<div class="content"> <div class="content">

View File

@ -47,6 +47,7 @@
else if (fct == "startGame") { else if (fct == "startGame") {
let names = msg.names let names = msg.names
setupGame(names) setupGame(names)
alert('game is set up')
} }
else { else {
alert('unknown command: '+event.data); alert('unknown command: '+event.data);
@ -55,11 +56,10 @@
socket.onclose = function(event) { socket.onclose = function(event) {
if (event.wasClean) { 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 { } else {
// e.g. server process killed or network down //alert('closed unclean');
// event.code is usually 1006 in this case
//alert('[close] Connection died');
} }
}; };

View File

@ -96,7 +96,9 @@ async def websocket(ws):
color = x['color'] color = x['color']
await set_trump_color(player, color) await set_trump_color(player, color)
elif fct == "requestInit": elif fct == "requestInit":
print("before init")
await initGame(ws); await initGame(ws);
print("after init")
else: else:
print("confused :(") print("confused :(")