From 3dd7583fdc4063f09a033aa1e0ed4a812117e81d Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Tue, 10 May 2022 05:13:24 -0700 Subject: [PATCH] Add device-find, client-find server commands Reviewed By: passy Differential Revision: D36098171 fbshipit-source-id: f0d0bbefcafc57a6413f9ffe8da271419c0d4deb --- desktop/flipper-common/src/server-types.tsx | 4 ++++ desktop/flipper-server-core/src/FlipperServerImpl.tsx | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/desktop/flipper-common/src/server-types.tsx b/desktop/flipper-common/src/server-types.tsx index 2cbafca3d..8aa620564 100644 --- a/desktop/flipper-common/src/server-types.tsx +++ b/desktop/flipper-common/src/server-types.tsx @@ -209,6 +209,9 @@ export type FlipperServerCommands = { 'get-config': () => Promise; 'get-changelog': () => Promise; 'device-list': () => Promise; + 'device-find': ( + deviceSerial: string, + ) => Promise; 'device-take-screenshot': (serial: string) => Promise; // base64 encoded buffer 'device-start-screencapture': ( serial: string, @@ -225,6 +228,7 @@ export type FlipperServerCommands = { 'device-navigate': (serial: string, location: string) => Promise; 'metro-command': (serial: string, command: string) => Promise; 'client-list': () => Promise; + 'client-find': (clientId: string) => Promise; 'client-request': (clientId: string, payload: any) => Promise; 'client-request-response': ( clientId: string, diff --git a/desktop/flipper-server-core/src/FlipperServerImpl.tsx b/desktop/flipper-server-core/src/FlipperServerImpl.tsx index 0b17504ab..43afbfb64 100644 --- a/desktop/flipper-server-core/src/FlipperServerImpl.tsx +++ b/desktop/flipper-server-core/src/FlipperServerImpl.tsx @@ -340,6 +340,9 @@ export class FlipperServerImpl implements FlipperServer { ), 'get-config': async () => this.config, 'get-changelog': getChangelog, + 'device-find': async (deviceSerial) => { + return this.devices.get(deviceSerial)?.info; + }, 'device-list': async () => { return Array.from(this.devices.values()).map((d) => d.info); }, @@ -363,6 +366,9 @@ export class FlipperServerImpl implements FlipperServer { } device.sendCommand(command); }, + 'client-find': async (clientId) => { + return this.server.connections.get(clientId)?.client; + }, 'client-list': async () => { return Array.from(this.server.connections.values()).map((c) => c.client); },