From deaf2359b1619079424c9cb1ddfdd3587d6c318c Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Tue, 10 May 2022 05:13:24 -0700 Subject: [PATCH] Implement HeadlessClient Reviewed By: lblasa Differential Revision: D36130082 fbshipit-source-id: 00f9709d9a4f245063ae428521031afe74a521d6 --- .../src/HeadlessClient.tsx | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 desktop/flipper-server-companion/src/HeadlessClient.tsx diff --git a/desktop/flipper-server-companion/src/HeadlessClient.tsx b/desktop/flipper-server-companion/src/HeadlessClient.tsx new file mode 100644 index 000000000..c42d07b37 --- /dev/null +++ b/desktop/flipper-server-companion/src/HeadlessClient.tsx @@ -0,0 +1,40 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import {ClientQuery, FlipperServer, Logger} from 'flipper-common'; +import { + AbstractClient, + ClientConnection, + BaseDevice, +} from 'flipper-frontend-core'; +import {_SandyPluginDefinition} from 'flipper-plugin'; + +export class HeadlessClient extends AbstractClient { + constructor( + id: string, + query: ClientQuery, + conn: ClientConnection | null | undefined, + logger: Logger, + plugins: Set | null | undefined, + device: BaseDevice, + flipperServer: FlipperServer, + private loadablePlugins: Map, + ) { + super(id, query, conn, logger, plugins, device, flipperServer); + } + + // Headless client never starts plugins automaticaly to preserve server resources + shouldConnectAsBackgroundPlugin() { + return false; + } + + async getPlugin(pluginId: string) { + return this.loadablePlugins.get(pluginId); + } +}