Implement sending messages from a server add-on

Reviewed By: mweststrate

Differential Revision: D34074383

fbshipit-source-id: de85e7a22dc9bb780163fc5b522708e8bc976df3
This commit is contained in:
Andrey Goncharov
2022-02-28 03:50:34 -08:00
committed by Facebook GitHub Bot
parent 842b2c810a
commit db976d5113
6 changed files with 82 additions and 19 deletions

View File

@@ -32,6 +32,7 @@ import {
installPluginFromNpm,
} from 'flipper-plugin-lib';
import {ServerAddOn} from './ServerAddOn';
import {FlipperServerForServerAddOn} from './ServerAddOnDesktopToModuleConnection';
const maxInstalledPluginVersionsToKeep = 2;
@@ -50,6 +51,8 @@ const isExecuteMessage = (message: object): message is ExecuteMessage =>
export class PluginManager {
private readonly serverAddOns = new Map<string, ServerAddOn>();
constructor(private readonly flipperServer: FlipperServerForServerAddOn) {}
async start() {
// This needn't happen immediately and is (light) I/O work.
setTimeout(() => {
@@ -183,8 +186,11 @@ export class PluginManager {
return;
}
const newServerAddOn = await ServerAddOn.start(pluginName, owner, () =>
this.serverAddOns.delete(pluginName),
const newServerAddOn = await ServerAddOn.start(
pluginName,
owner,
() => this.serverAddOns.delete(pluginName),
this.flipperServer,
);
this.serverAddOns.set(pluginName, newServerAddOn);
}