diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-02-17 09:53:39 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-02-17 09:53:39 +0100 |
commit | c45d0923b65c7409dcb18554c3e1dd00324e3f92 (patch) | |
tree | 29055c1fdd758b97a6fae520ddc2612e2dbb5109 /api/game/socket.py | |
parent | 084a41d7e667daa2c773a063ee3e42cd093323db (diff) |
working socket.io messages
Diffstat (limited to 'api/game/socket.py')
-rw-r--r-- | api/game/socket.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/api/game/socket.py b/api/game/socket.py index 7931ada..c4e5ac7 100644 --- a/api/game/socket.py +++ b/api/game/socket.py @@ -1,12 +1,30 @@ from flask import Blueprint, request, make_response -from flask_socketio import SocketIO, emit, disconnect, Namespace -from main import socketio +from flask_socketio import SocketIO, emit, disconnect, Namespace, emit import time import json class GameSocketNamespace(Namespace): def connect(self): - print("connection") + print("new connection") + emit("gert", {"gert": "banaan"}) -socketio.on_namespace(GameSocketNamespace("/game/socket")) + def on_connect(self): + print("new connection") + emit("gert", {"gert": "banaan"}) + + def on_disconnect(self): + print("disconnect") + + def new_move(self, data): + print("new_move") + print(data) + + def resign(self, data): + print("resign") + print(data) + +def run(app): + socketio = SocketIO(app) + socketio.on_namespace(GameSocketNamespace("/game/socket")) + socketio.run(app, host="127.0.0.1", port=5000, debug=True) |