def forceJoinRoom(roomId): roomId = str(roomId) username = request.environ["AUTH_USER"] if not roomSuite.hasRoom(roomId): return { "status": "error", "reason": "noSuchRoom" } room = roomSuite.getRoom(roomId) existingSession = room.getMemberSession(username) if existingSession is not None and existingSession != request.sid: # Disconnect the existing connection socketio.emit("roomUpdate", { "status": "error", "reason": "alreadyJoined" }) room.leave(existingSession) room.join(username, request.sid) return { "status": "success", "roomLayout": room.studentLayout(), "answers": room.getMemberAnswers(username) }
def updateRoomLayout(room): overview = roomOverview(room) socketio.emit("room", overview, room="teacher:room." + room.id) layout = room.studentLayout() for username, sid in room.memberSessions.items(): socketio.emit("roomUpdate", { "status": "success", "roomLayout": layout, "answers": room.getMemberAnswers(username) }, sid=sid)
def deleteRoom(roomId): username = request.environ["AUTH_USER"] if not isTeacher(username): return if not roomSuite.hasRoom(roomId): return roomSuite.deleteRoom(roomId) dbFun.deleteRoom(db, roomId) socketio.emit("room", { "status": "error", "reason": "noSuchRoom" }, room="teacher:room." + roomId) socketio.close_room("teacher:room." + roomId) socketio.emit("room", { "status": "error", "reason": "noSuchRoom" }, room="student:room." + roomId) socketio.close_room("student:room." + roomId) updateRoomsOverview()
def updateRoomOverview(room): overview = roomOverview(room) socketio.emit("room", overview, room="teacher:room." + room.id)
def updateRoomsOverview(): socketio.emit("rooms", roomsOverview(roomSuite), room="teacher:roomsOverview")