feat: add ability to ping/pong with client
This commit is contained in:
3
main.py
3
main.py
@@ -83,6 +83,9 @@ def create_game(game_id, client_id=None, player=None):
|
|||||||
async def init(websocket, path):
|
async def init(websocket, path):
|
||||||
try:
|
try:
|
||||||
async for message in websocket:
|
async for message in websocket:
|
||||||
|
if message == "ping":
|
||||||
|
await websocket.send("pong");
|
||||||
|
else:
|
||||||
data = json.loads(message)
|
data = json.loads(message)
|
||||||
if data["action"] == "enter_game":
|
if data["action"] == "enter_game":
|
||||||
await enter_game(data["gameId"], data["clientId"], websocket)
|
await enter_game(data["gameId"], data["clientId"], websocket)
|
||||||
|
|||||||
Reference in New Issue
Block a user