Aplikacja natywna nie działa w rozszerzeniu Chrome

Próbuję interfejsu API Chrome Native Messaging dla rozszerzenia Chrome.

Manifest.json dla natywnej aplikacji:

{
  "name": "app.native",
  "description": "Native Message API Test.",
  "path": "native.exe",
  "type": "stdio",
  "allowed_origins": ["chrome-extension://kembignchdjhopkkcolnamikcenaocdm/"]
}

Wartość rejestru systemu Windows:

HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\app.native=D:\connectNative\manifest.json

Próbowałem teżD:\\\\connectNative\\\\manifest.json

I dodam „nativeMessaging” do „uprawnień” w rozszerzeniu Chrome.jpg manifest.

Natywna aplikacja cpp:

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main(int argc, char* argv[]) {
    string input = "";
    string message="{\"text\": \"This is a response message\",\"num\": \"three\"}";
    unsigned int len = message.length();
    cout << char(((len>>0) & 0xFF))
         << char(((len>>8) & 0xFF))
         << char(((len>>16) & 0xFF))
         << char(((len>>24) & 0xFF));
    cout << message <<endl;
    getline(cin, input);
    cout << "You entered: " << input << endl;
    ofstream myfile;
    myfile.open ("example.txt");
    myfile << "Writing this to a file.\n";
    myfile << input;
    myfile.close();

    return 0;
}

Po tym wszystkim próbuję w moim rozszerzeniu Chrome:

var testport = chrome.runtime.connectNative('app.native');
testport.onMessage.addListener(function(msg) {
    console.log("Received" + msg);
});
testport.onDisconnect.addListener(function() {
  console.log("Disconnected");
});

Nie może odebrać żadnej wiadomości i zawsze drukuje „Odłączony”.

Próbuję połączyć się z nieistniejącą aplikacją, nadal drukuje „Odłączony”, więc wiem, że ta natywna aplikacja nie jest skonfigurowana prawidłowo.

Czy ktoś może wskazać, co jest nie tak lub co przegapiłem?

questionAnswers(2)

yourAnswerToTheQuestion