aboutsummaryrefslogtreecommitdiff
path: root/api/game
diff options
context:
space:
mode:
Diffstat (limited to 'api/game')
-rw-r--r--api/game/socket.py26
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)