force users to pick capable display range.

This commit is contained in:
KingKDot
2026-07-13 09:34:16 -05:00
parent 1bc6364055
commit 447efa5192
16 changed files with 651 additions and 66 deletions
@@ -221,6 +221,7 @@ type WsLifecycleDeps = {
) => void;
handleNotificationScreenshotResult: (clientId: string, payload: any) => void;
handleConsoleOutput: (clientId: string, payload: any) => void;
handleDesktopEncoderCapabilities: (clientId: string, payload: any) => void;
handleFileBrowserMessage: (clientId: string, payload: any) => void;
handleProxyTunnelData: (clientId: string, connectionId: string, data: Uint8Array) => void;
handleProxyTunnelClose: (clientId: string, connectionId: string) => void;
@@ -795,6 +796,9 @@ export async function handleWebSocketMessage(
case "console_output":
deps.handleConsoleOutput(client.id, payload);
break;
case "desktop_encoder_capabilities":
deps.handleDesktopEncoderCapabilities(client.id, payload);
break;
case "file_list_result":
case "file_download":
case "file_upload_result":
@@ -368,6 +368,11 @@ export function handleRemoteDesktopViewerMessage(ws: ServerWebSocket<SocketData>
logger.debug(`[rd] inbound viewer msg type=${payload.type} client=${clientId}`);
switch (payload.type) {
case "desktop_encoder_capabilities":
sendDesktopCommand(target, "desktop_encoder_capabilities", {
display: Number((payload as any).display) || 0,
});
break;
case "desktop_start":
logger.debug(`[rd-debug] desktop_start requested client=${clientId} session=${ws.data.sessionId || ""} state=${JSON.stringify(state)} viewers=${sessionManager.getRdSessionsForClient(clientId).length} webrtc=${(payload as any).webrtc === true}`);
if (!state.isStreaming) {
@@ -554,6 +559,18 @@ export function handleRemoteDesktopViewerMessage(ws: ServerWebSocket<SocketData>
}
break;
}
case "desktop_set_profile": {
const newMaxHeight = Number((payload as any).maxHeight) || 0;
const newMaxFps = clampDesktopFps((payload as any).fps);
if (state.maxHeight !== newMaxHeight || state.maxFps !== newMaxFps) {
sendDesktopCommand(target, "desktop_set_profile", { maxHeight: newMaxHeight, fps: newMaxFps });
state.maxHeight = newMaxHeight;
state.maxFps = newMaxFps;
rdStreamingState.set(clientId, state);
logger.debug(`[rd] set stream profile max_height=${newMaxHeight} fps=${newMaxFps}`);
}
break;
}
case "desktop_set_fps": {
const newMaxFps = clampDesktopFps((payload as any).fps);
if (state.maxFps !== newMaxFps) {
@@ -1425,6 +1442,12 @@ export function sendHVNCCommand(target: ClientInfo | undefined, commandType: str
}
}
export function handleDesktopEncoderCapabilities(clientId: string, payload: any) {
for (const session of sessionManager.getRdSessionsForClient(clientId)) {
safeSendViewer(session.viewer, payload);
}
}
(globalThis as any).__hvncBroadcast = (clientId: string, bytes: Uint8Array, header?: any): boolean => {
const state = hvncStreamingState.get(clientId) || defaultHVNCStreamingState();
if (!state.isStreaming) {