def handle_connect(): game, player_id = authenticate(session) players = game["player_positions"] if not game: print('Invalid connection. Disconnecting!') return disconnect() game_id = game["game_id"] print("Player %d connected to game %s" % (players[player_id], game_id)) if game_id not in rooms(): join_room(game_id) json_data = json_game_state(game) emit('game_state', json_data, room=game_id)
def leave_channel(message): leave_room(message['channel']) emit('log', { 'data': 'leave channel: {0}'.format(', '.join(rooms())) })
def join_channel(message): join_room(message['channel']) emit('log', { 'data': 'join channel: {0}'.format(', '.join(rooms())) })