Implement sending messages from desktop to add-on

Reviewed By: antonk52

Differential Revision: D34239803

fbshipit-source-id: 1a18d522ba877ade3d0703fbb374c15b596241d7
This commit is contained in:
Andrey Goncharov
2022-02-28 03:50:34 -08:00
committed by Facebook GitHub Bot
parent 2ce037d96b
commit 4067f5bd88
9 changed files with 54 additions and 7 deletions

View File

@@ -64,7 +64,7 @@ export class ServerAddOn {
);
const serverAddOnModuleToDesktopConnection =
new ServerAddOnModuleToDesktopConnection();
new ServerAddOnModuleToDesktopConnection(pluginName);
const cleanup = await serverAddOn(serverAddOnModuleToDesktopConnection, {
flipperServer,

View File

@@ -27,6 +27,10 @@ export class ServerAddOnModuleToDesktopConnection
{
private subscriptions: Map<string, FlipperPluginReceiver> = new Map();
constructor(private readonly pluginName: string) {
super();
}
send(method: string, params: unknown) {
const event = 'message';
const message: ServerAddOnModuleToDesktopConnectionEvents[typeof event] = {
@@ -34,7 +38,7 @@ export class ServerAddOnModuleToDesktopConnection
params: {
method,
params,
api: '', // TODO: Consider using here pluginName and validate it
api: this.pluginName,
},
};
this.emit('message', message);