示例#1
0
    def on_create_user(self, data):

        try:
            user = loads(data)
        except ValueError:
            emit("error", "Invalid input data when creating a user.")
            return

        user_uuid, players_left = Database.create_player(
            user["room_id"], user["username"], request.sid)

        if user_uuid is None:
            emit("error", "Invalid input data when creating a user.")

        emit("user_created", {"user_key": user_uuid}, json=True)
        emit("players_count_changed", {"players_left": players_left},
             json=True,
             broadcast=True)
示例#2
0
from bluetato_server.database import Database

room_id = '1'
print("CREATE ", Database.create_room(3))

user_id = 'id1'
session_id = 's1'
name = 'A'
print("+-> ", Database.create_player(room_id, name, session_id, user_id))
print("Adding questions")
print(Database.player_enters_question(room_id, user_id, 'Qa'))
print(Database.player_enters_question(room_id, user_id, 'Qb'))
print(Database.player_enters_question(room_id, user_id, 'Qc'))
print("Ending questions")
print("SessionId ", Database.get_session_id(room_id, '1'))

user_id = 'id2'
session_id = 's2'
name = 'B'
print("+-> ", Database.create_player(room_id, name, session_id, user_id))
print("Adding questions")
print(Database.player_enters_question(room_id, user_id, 'Qd'))
print(Database.player_enters_question(room_id, user_id, 'Qe'))
print(Database.player_enters_question(room_id, user_id, 'Qf'))
print("Ending questions")

user_id = 'id3'
session_id = 's3'
name = 'C'
print("+-> ", Database.create_player(room_id, name, session_id, user_id))