Update
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,2 +1,7 @@
|
|||||||
.env
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
node_modules/
|
node_modules/
|
||||||
|
docker-compose.override.yml
|
||||||
|
target/
|
||||||
|
*.log
|
||||||
|
|||||||
@@ -27,14 +27,14 @@ services:
|
|||||||
context: ./web
|
context: ./web
|
||||||
container_name: sova-web
|
container_name: sova-web
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
|
||||||
- "3000:3000"
|
|
||||||
environment:
|
environment:
|
||||||
- SOVA_HOST=sova-server
|
- SOVA_HOST=sova-server
|
||||||
- SOVA_PORT=8080
|
- SOVA_PORT=8080
|
||||||
- SOVA_PASSWORD=${SOVA_PASSWORD}
|
- SOVA_PASSWORD=${SOVA_PASSWORD}
|
||||||
depends_on:
|
depends_on:
|
||||||
- sova-server
|
- sova-server
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
const $ = (id) => document.getElementById(id);
|
const $ = (id) => document.getElementById(id);
|
||||||
const ws = new WebSocket(`ws://${location.host}`);
|
const ws = new WebSocket(`${location.protocol === "https:" ? "wss:" : "ws:"}//${location.host}`);
|
||||||
|
|
||||||
ws.onmessage = (e) => {
|
ws.onmessage = (e) => {
|
||||||
const s = JSON.parse(e.data);
|
const s = JSON.parse(e.data);
|
||||||
|
|||||||
@@ -20,6 +20,21 @@ let state = {
|
|||||||
connected: false,
|
connected: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// --- Helpers ---
|
||||||
|
|
||||||
|
/** Recursively convert Map objects (from useMap decode) to plain objects */
|
||||||
|
function mapToObj(val) {
|
||||||
|
if (val instanceof Map) {
|
||||||
|
const obj = {};
|
||||||
|
for (const [k, v] of val) {
|
||||||
|
if (typeof k === "string" || typeof k === "number") obj[k] = mapToObj(v);
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
if (Array.isArray(val)) return val.map(mapToObj);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
// --- Wire protocol ---
|
// --- Wire protocol ---
|
||||||
|
|
||||||
function buildFrame(msg) {
|
function buildFrame(msg) {
|
||||||
@@ -60,7 +75,11 @@ function parseFrames(buffer) {
|
|||||||
try {
|
try {
|
||||||
messages.push(decode(payload));
|
messages.push(decode(payload));
|
||||||
} catch {
|
} catch {
|
||||||
// skip malformed msgpack
|
try {
|
||||||
|
messages.push(mapToObj(decode(payload, { useMap: true })));
|
||||||
|
} catch {
|
||||||
|
// skip truly malformed msgpack
|
||||||
|
}
|
||||||
}
|
}
|
||||||
offset += 8 + len;
|
offset += 8 + len;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user