pieds
This commit is contained in:
parent
1e4cd71e06
commit
e84731e8de
4 changed files with 35 additions and 15 deletions
|
|
@ -19,6 +19,8 @@ await authenticate();
|
|||
// Sockets
|
||||
//
|
||||
let room = window.location.pathname.split("/")[1];
|
||||
const update_waitlist = [];
|
||||
const initialized = false;
|
||||
|
||||
if (!room) {
|
||||
room = "epi-place";
|
||||
|
|
@ -50,7 +52,15 @@ socket.on("message", async (response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
initCanvas(await getCurrentRoomConfig(), pixels);
|
||||
initCanvas(await getCurrentRoomConfig(room), pixels);
|
||||
while (update_waitlist.length > 0) {
|
||||
const obj = update_waitlist.pop();
|
||||
|
||||
if (obj) {
|
||||
renderCanvasUpdate(obj.color, obj.posX, obj.posY);
|
||||
}
|
||||
}
|
||||
|
||||
console.debug("Loaded canvas");
|
||||
});
|
||||
|
||||
|
|
@ -71,7 +81,7 @@ socket.on("pixel-update", async (msg) => {
|
|||
color,
|
||||
} = msg.result.data.json;
|
||||
|
||||
const cfg = await getCurrentRoomConfig();
|
||||
const cfg = await getCurrentRoomConfig(room);
|
||||
|
||||
if (!cfg || !cfg.settings || !cfg.settings.roomColors) {
|
||||
console.error(
|
||||
|
|
@ -81,6 +91,11 @@ socket.on("pixel-update", async (msg) => {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!initialized) {
|
||||
update_waitlist.push({ posX, posY, color });
|
||||
return;
|
||||
}
|
||||
|
||||
renderCanvasUpdate(color, posX, posY);
|
||||
});
|
||||
|
||||
|
|
@ -102,6 +117,4 @@ placeButtonElt.addEventListener("click", () => {
|
|||
placePixelButton();
|
||||
});
|
||||
|
||||
export {
|
||||
room
|
||||
}
|
||||
export { room };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue