Last active
November 20, 2017 16:39
-
-
Save alexstrat/3197b71d8e8ff0223fdd5c3f217eefa0 to your computer and use it in GitHub Desktop.
NativeMessaging client API example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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