Implement sending messages from desktop to add-on
Reviewed By: antonk52 Differential Revision: D34239803 fbshipit-source-id: 1a18d522ba877ade3d0703fbb374c15b596241d7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2ce037d96b
commit
4067f5bd88
@@ -64,7 +64,7 @@ export class ServerAddOn {
|
||||
);
|
||||
|
||||
const serverAddOnModuleToDesktopConnection =
|
||||
new ServerAddOnModuleToDesktopConnection();
|
||||
new ServerAddOnModuleToDesktopConnection(pluginName);
|
||||
|
||||
const cleanup = await serverAddOn(serverAddOnModuleToDesktopConnection, {
|
||||
flipperServer,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user