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
@@ -7,7 +7,11 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {FlipperServer, ServerAddOnControls} from 'flipper-common';
|
||||
import {
|
||||
FlipperServer,
|
||||
ServerAddOnControls,
|
||||
deserializeRemoteError,
|
||||
} from 'flipper-common';
|
||||
|
||||
export const createServerAddOnControls = (
|
||||
flipperServer: Pick<FlipperServer, 'exec'>,
|
||||
@@ -16,4 +20,23 @@ export const createServerAddOnControls = (
|
||||
flipperServer.exec('plugins-server-add-on-start', pluginName, owner),
|
||||
stop: (pluginName, owner) =>
|
||||
flipperServer.exec('plugins-server-add-on-stop', pluginName, owner),
|
||||
sendMessage: async (pluginName, method, params) => {
|
||||
const res = await flipperServer.exec(
|
||||
'plugins-server-add-on-request-response',
|
||||
{
|
||||
method: 'execute',
|
||||
params: {
|
||||
method,
|
||||
api: pluginName,
|
||||
params,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (res.error) {
|
||||
throw deserializeRemoteError(res.error);
|
||||
}
|
||||
|
||||
return res.success;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user