This commit is contained in:
Guillem George 2026-05-16 13:38:37 +02:00
parent 02ac670fe1
commit 814e559ccd
5 changed files with 132 additions and 32 deletions

View file

@ -1,7 +1,35 @@
// FIXME: This file should handle the room canvas API
// Link buttons to their respective functions
// Functions may include:
// - getCanvas (get the canvas of a room and deserialize it)
// - subscribeToRoom (subscribe to the stream of a room)
// - getPixelInfo (get the pixel info of a room)
// - placePixel (place a pixel in a room)
import { authedAPIRequest } from "../../utils/auth";
// get the canvas of a room and deserialize it
async function getCanvas(room) {
if (!room) {
console.error("Cannot fetch canvas of an undefined room");
return null;
}
const response = await authedAPIRequest("/rooms/" + room + "/canvas", {
method: "GET",
});
if (!response.ok) {
console.error("Could not retrieve room canvas: " + response.statusText);
console.debug(await response.text());
return null;
}
const res = await response.json();
console.debug(`Retrieved canvas for room ${room}:`);
console.debug(res);
return res;
}
// subscribe to the stream of a room
function subscribeToRoom() {}
// get the pixel info of a room
function getPixelInfo() {}
// place a pixel in a room
function placePixel() {}
export { getCanvas, subscribeToRoom, getPixelInfo, placePixel };