control: seed events, add tests, update remote doc

This commit is contained in:
Peter Steinberger
2025-12-08 22:03:46 +01:00
parent 9c54e48194
commit e38bdd0d2d
3 changed files with 112 additions and 2 deletions

View File

@@ -54,6 +54,17 @@ export async function startControlChannel(
const server = net.createServer((socket) => {
socket.setEncoding("utf8");
clients.add(socket);
// Seed relay status + last heartbeat for new clients.
write(socket, {
type: "event",
event: "relay-status",
payload: { state: "running" },
});
const last = getLastHeartbeatEvent();
if (last)
write(socket, { type: "event", event: "heartbeat", payload: last });
let buffer = "";
socket.on("data", (chunk) => {