From 1787205f04c9008a753618839bc8da72708f5cab Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 19 Feb 2021 19:39:01 +0100 Subject: working socket.io messages v2 --- api/game/socket.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'api/game/socket.py') diff --git a/api/game/socket.py b/api/game/socket.py index fdeac73..55bff0f 100644 --- a/api/game/socket.py +++ b/api/game/socket.py @@ -1,12 +1,10 @@ from flask import Blueprint, request, make_response -from flask_socketio import SocketIO, emit, disconnect, emit +from flask_socketio import SocketIO, emit, Namespace from game.voerbak_connector import bord from db import cursor import time import json -namespace = "/game/socket" - class game: def __init__(self, game_id): self.game_id = game_id @@ -21,12 +19,14 @@ class game: def run(app): io = SocketIO(app, cors_allowed_origins="*") - @io.on("new_move", namespace) - def new_move(data): - print(data) + namespace = "/game/socket/" + @io.on("connect", namespace) + def connect(): + print("new connection", namespace) - @io.on("resign", namespace) - def resign(data): + @io.on("new_move") + def connect(data): + print("new_move") print(data) io.run(app, host="127.0.0.1", port=5000, debug=True) -- cgit v1.2.3