serve new games via socket
This commit is contained in:
parent
085ae0f682
commit
1a8c4de394
2 changed files with 5 additions and 5 deletions
|
@ -1,12 +1,13 @@
|
||||||
from flask import Blueprint, request, jsonify, session
|
from flask import Blueprint, request, jsonify, session
|
||||||
from models.User import User, user_schema, users_schema
|
from models.User import User, user_schema, users_schema
|
||||||
from models.GameRoom import GameRoom, rooms_schema, room_schema
|
from models.GameRoom import GameRoom, rooms_schema, room_schema
|
||||||
from models.Game import Game
|
from models.Game import Game, game_schema
|
||||||
from database import db
|
from database import db
|
||||||
from ..decorators import jwt_required
|
from ..decorators import jwt_required
|
||||||
import jwt
|
import jwt
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
from websockets.socket import new_game_notice
|
||||||
|
|
||||||
api_games = Blueprint('api_games', __name__, url_prefix='/api/games')
|
api_games = Blueprint('api_games', __name__, url_prefix='/api/games')
|
||||||
|
|
||||||
|
@ -35,7 +36,8 @@ def post_game():
|
||||||
print('game added')
|
print('game added')
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
print('game')
|
print('game')
|
||||||
print(game)
|
print(game_schema.dumps(game))
|
||||||
|
new_game_notice(room=game.game_room, game=game_schema.dumps(game))
|
||||||
response = {
|
response = {
|
||||||
'status': 'success',
|
'status': 'success',
|
||||||
'message': 'Game created',
|
'message': 'Game created',
|
||||||
|
|
|
@ -35,9 +35,7 @@ def join_room_notice(room):
|
||||||
emit('connected', {'roomspace': f'/{room}'})
|
emit('connected', {'roomspace': f'/{room}'})
|
||||||
|
|
||||||
def new_game_notice(room, game):
|
def new_game_notice(room, game):
|
||||||
@socketio.on('connect', namespace=f'/{room}')
|
socketio.emit('new game', game, broadcast=True, namespace=f'/{room}')
|
||||||
def emit_game(game):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def new_room_notice(room):
|
def new_room_notice(room):
|
||||||
|
|
Loading…
Reference in a new issue