2026-05-16 11:14:39 +02:00
|
|
|
import { authedAPIRequest } from "../utils/auth";
|
2026-05-15 11:08:23 +02:00
|
|
|
// 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)
|
2026-05-15 22:59:15 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
// 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');
|
|
|
|
|
// });
|
2026-05-16 11:14:39 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
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 };
|