def join_tournament(message): hashid = message['hashid'] tournament = Tournament.query.filter_by(hashid=hashid).first() if not tournament or tournament in current_user.tournaments: return current_user.tournaments.append(tournament) db.session.commit() broadcast_online_players(room=hashid)
def kick_player(message): hashid = message['hashid'] user_id = message['user_id'] tournament = Tournament.query.filter_by(hashid=hashid).first() user = User.query.filter_by(id=user_id).first() if not tournament or not user or tournament not in user.tournaments: return user.tournaments.remove(tournament) db.session.commit() broadcast_online_players(room=hashid)
def connect_chat(): # print('Client connected', request.sid) broadcast_online_players(broadcast=False)
def chat_broadcast_online_players_periodic(): start = time.process_time() broadcast_online_players() return str(time.process_time() - start)
def connect(): # print('Client connected', request.sid) broadcast_online_players()
def init(message): room = message['hashid'] if 'hashid' in message else 'public_chat' join_room(room) broadcast_online_players(broadcast=False, room=room)
def chat_broadcast_online_players_periodic(): broadcast_online_players() return jsonify('success')