SAE-A2-TruthInquiry/truthseeker/routes/routes_socketio.py
2023-01-05 23:14:40 +01:00

20 lines
527 B
Python

from flask_socketio import join_room
import socketio
from truthseeker import APP
from truthseeker.logic import game_logic
@APP.socketio_app.on('connect')
def connect(auth):
if not (auth and "game_id" in auth):
raise socketio.exceptions.ConnectionRefusedError("Invalid connection data passed")
game = game_logic.get_game(auth["game_id"])
if not game:
raise socketio.exceptions.ConnectionRefusedError("No game with this ID")
room = join_room("game."+auth["game_id"])
join_room(room)