serve new games via socket

This commit is contained in:
Sorrel Bri 2019-10-10 23:31:27 -07:00
parent 085ae0f682
commit 1a8c4de394
2 changed files with 5 additions and 5 deletions

View file

@ -1,12 +1,13 @@
from flask import Blueprint, request, jsonify, session
from models.User import User, user_schema, users_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 ..decorators import jwt_required
import jwt
import os
import json
from websockets.socket import new_game_notice
api_games = Blueprint('api_games', __name__, url_prefix='/api/games')
@ -35,7 +36,8 @@ def post_game():
print('game added')
db.session.commit()
print('game')
print(game)
print(game_schema.dumps(game))
new_game_notice(room=game.game_room, game=game_schema.dumps(game))
response = {
'status': 'success',
'message': 'Game created',

View file

@ -35,9 +35,7 @@ def join_room_notice(room):
emit('connected', {'roomspace': f'/{room}'})
def new_game_notice(room, game):
@socketio.on('connect', namespace=f'/{room}')
def emit_game(game):
pass
socketio.emit('new game', game, broadcast=True, namespace=f'/{room}')
def new_room_notice(room):