Close Native Host when Chrome is closed by the user

前端 未结 1 1216
半阙折子戏
半阙折子戏 2021-01-28 19:43

I am working on a Chrome extension that uses a C++ Native Host. In a background.js script (persistent set to false), using chrome.onstartup event, I create the connection to the

相关标签:
1条回答
  • 2021-01-28 20:14

    When Chrome terminates or your extension is unloaded, it will send -1 message to your native messaging host. You will have to check for that value, assuming your native messaging host is written in C++ then this is what you should do:

    int read_char = ::getchar();
    if (read_char == -1) {
    // Do termination work here...
    }
    
    0 讨论(0)
提交回复
热议问题