Ejemplo n.º 1
0
def get_room_list():
    global room_list, connected_users
    access_token = get_token_auth_header()
    rooms = []
    for room in room_list:
        rooms.append({
            'name':
            room_list[room]['name'],
            'id':
            room_list[room]['room_id'],
            'players':
            'started' if room_list[room]['started'] else
            room_list[room]['players']['total_count'],
            'old':
            False
        })
    cur.execute(
        "SELECT room_name, room_id, player1, player2, player3, started FROM rooms WHERE player1 = %s AND complete = 0",
        (connected_users[access_token]['auth0_code'], ))
    for room in cur.fetchall():
        if room[1] not in list(room_list.keys()):
            rooms.append({
                'name':
                room[0],
                'id':
                room[1],
                'players':
                'started'
                if room[5] == 1 else len([p for p in room[2:4] if p != None]),
                'old':
                True
            })
    return jsonify(rooms)
Ejemplo n.º 2
0
def send_all_infomation(data):
    rooms = []
    for room_id in ROOM_NUM:
        room = {}
        room["roomid"] = room_id
        room["mem_num"] = ROOM_NUM[room_id]
        room["name"] = ROOM_NAME[room_id]
        room["inner"] = ROOM[room_id]
        rooms.append(room)
    socketio.emit('get_all_rooms',rooms,room=request.sid)
Ejemplo n.º 3
0
def chatroom_creation(room):
    if room in rooms:
        emit('chatroom_error', 'This room name is already taken!')

    else:
        rooms.append(room)
        my_messages[room] = []
        join_room(room)
        print(rooms)
        print(room)
        data = {'room': room, 'messages': my_messages[room]}
        emit('join_chatroom', data)
Ejemplo n.º 4
0
	def __init__(self, name, prev_Room, user1):
		self.name = name
		self.messages = []
		self.users = [user1]
		self.member_count = 1
		leave_room(prev_Room)
		if session['user'].current_room is not None:
			for i in rooms:
				if i.name == session["user"].current_room:
					i.users.remove(session["user"].name)
					i.member_count -= 1
					break
		join_room(name)
		session['user'].current_room = self
		rooms.append(self)
Ejemplo n.º 5
0
def monitor_connect():
    join_room(MONITOR_ROOM)
    rooms = []
    for room_id in ROOM_NUM:
        room = {}
        room["roomid"] = room_id
        room["mem_num"] = ROOM_NUM[room_id]
        room["name"] = ROOM_NAME[room_id]
        if len(ROOM[room_id]['songlist']) > 0:
            room["song_playing"] = ROOM[room_id]['songlist'][0]
        else:
            room["song_playing"] = ''
        rooms.append(room)
    # print(rooms)
    socketio.emit('get_rooms_status',rooms,room=request.sid)
Ejemplo n.º 6
0
def create_room():
    if request.method == 'POST':
        room = request.form['room']
        if len(room) < 2:
            return jsonify({
                "type": "error",
                "response": "Must be higher than 1 letters"
            })
        if room in rooms:
            return jsonify({
                "type": "error",
                "response": "Room already registered"
            })
        rooms.append(room)
        return jsonify({"type": "success", "response": "Room Created"})
    return jsonify({})
Ejemplo n.º 7
0
def join(message):
    join_room(message['room'])
    emit('join room',
         {'data': 'In rooms: '})

    for room in rooms:
        if room.roomName == message['room']:
            return

    room = Room()
    room.roomName = message['room']
    room.roomPassword = message['password']
    room.roomNum = len(rooms)
    room.roomPeople.append({'name': message['name'], 'sid': request.sid})
    rooms.append(room)

    print("join room")