comm works by json both ways now
This commit is contained in:
parent
ebf7878397
commit
1b9ccc65ab
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user