Add device-find, client-find server commands

Reviewed By: passy

Differential Revision: D36098171

fbshipit-source-id: f0d0bbefcafc57a6413f9ffe8da271419c0d4deb
This commit is contained in:
Andrey Goncharov
2022-05-10 05:13:24 -07:00
committed by Facebook GitHub Bot
parent 50111ef24b
commit 3dd7583fdc
2 changed files with 10 additions and 0 deletions

View File

@@ -209,6 +209,9 @@ export type FlipperServerCommands = {
'get-config': () => Promise<FlipperServerConfig>;
'get-changelog': () => Promise<string>;
'device-list': () => Promise<DeviceDescription[]>;
'device-find': (
deviceSerial: string,
) => Promise<DeviceDescription | undefined>;
'device-take-screenshot': (serial: string) => Promise<string>; // base64 encoded buffer
'device-start-screencapture': (
serial: string,
@@ -225,6 +228,7 @@ export type FlipperServerCommands = {
'device-navigate': (serial: string, location: string) => Promise<void>;
'metro-command': (serial: string, command: string) => Promise<void>;
'client-list': () => Promise<ClientDescription[]>;
'client-find': (clientId: string) => Promise<ClientDescription | undefined>;
'client-request': (clientId: string, payload: any) => Promise<void>;
'client-request-response': (
clientId: string,

View File

@@ -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);
},