import { authedAPIRequest } from "../utils/auth"; // FIXME: This file should handle the rooms API // Functions may include: // - fetchRoomConfig (get the configuration of a room) // - setCurrentRoomConfig (set the current room configuration and update the DOM accordingly) // - getCurrentRoomConfig (get the current room configuration) // - joinRoom (join a room by its slug) // - listRooms (list all the rooms available) // - createRoom (create a room) // - updateRoom (update a room's configuration) // - deleteRoom (delete a room) // // joinRoom notes // io.on('connection', (socket) => { // // join the room named 'some room' // socket.join('some room'); // // broadcast to all connected clients in the room // io.to('some room').emit('hello', 'world'); // // broadcast to all connected clients except those in the room // io.except('some room').emit('hello', 'world'); // // leave the room // socket.leave('some room'); // }); // async function fetchRoomConfig(room) { const response = await authedAPIRequest("/rooms/" + room + "/config"); if (!response.ok) { console.error("Could not retrieve room config: " + response.statusText); console.debug(await response.text()); return; } const obj = await response.json(); console.debug(`Retrieved config for room ${room}: ${obj}`); // Update HTML } export { fetchRoomConfig };