Enhance layout handling and debugging in WebSocketManager; update mock_backend and App.svelte for improved widget integration and console logging.

This commit is contained in:
Muratovakisa33
2026-03-08 22:59:40 +01:00
parent 64496cf038
commit 47bf577d7a
18 changed files with 563 additions and 110 deletions

View File

@@ -14,7 +14,7 @@ const sockets = new Map();
export function createConnection(wsIndex, ip, callbacks) {
const url = "ws://" + ip + ":81";
const socket = new WebSocket(url);
socket.binaryType = "blob"; // fix: set on instance, not on array
socket.binaryType = "blob";
sockets.set(wsIndex, socket);
socket.addEventListener("open", () => {
@@ -25,11 +25,15 @@ export function createConnection(wsIndex, ip, callbacks) {
if (callbacks.onMessage) callbacks.onMessage(wsIndex, event.data);
});
socket.addEventListener("close", () => {
socket.addEventListener("close", (ev) => {
if (socket.readyState !== 1) {
console.warn("[WS] closed before open", "url:", url, "wsIndex:", wsIndex, "code:", ev.code, "reason:", ev.reason || "");
}
if (callbacks.onClose) callbacks.onClose(wsIndex);
});
socket.addEventListener("error", () => {
console.warn("[WS] error connecting to", url, "wsIndex:", wsIndex, "- is mock_backend.py running on port 81?");
if (callbacks.onError) callbacks.onError(wsIndex);
});
}