Skip to content

Instantly share code, notes, and snippets.

@alexstrat
Last active November 20, 2017 16:39
Show Gist options
  • Save alexstrat/3197b71d8e8ff0223fdd5c3f217eefa0 to your computer and use it in GitHub Desktop.
Save alexstrat/3197b71d8e8ff0223fdd5c3f217eefa0 to your computer and use it in GitHub Desktop.
NativeMessaging client API example
const client = require('native-messaging-client');
// will look thru all the possible app manifest location
// and return the first manifest for the given app name
const manifest = await client.findNativeMessagingHost('app_name');
const messagingPort = new client.MessagingPort(manifest);
// will run the executbale, do the handshaek (?) and so on
await messagingPort.connect();
messagingPort.postMessage({foo: 'bar'});
messagingPort.on('message', msg => { console.log(msg) });
// we might need to close the thing when tab is closed
messagingPort.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment