我是開發Chrome擴展的初學者。我試圖在我的擴展和C++代碼之間實現本地消息傳遞。這裏是C++代碼調試Chrome本機消息
int main(int argc, char* argv[]) {
// Define our message
char message[] = "{\"text\": \"This is a response message\"}";
// Collect the length of the message
unsigned int len = strlen(message);
// We need to send the 4 bytes of length information
printf("%c%c%c%c", (char) (len & 0xff),
(char) ((len>>8) & 0xFF),
(char) ((len>>16) & 0xFF),
(char) ((len>>24) & 0xFF));
// Now we can output our message
printf("%s", message);
return 0;
}
的問題是該分機所不接受任何事情,我不知道如何來調試程序。我已經嘗試從終端打開Chrome,以便顯示錯誤,但沒有任何顯示。這裏是從background.js代碼
var port = chrome.runtime.connectNative('com.my_company.my_application');
port.onMessage.addListener(function(msg) {
console.log("Received" + msg);
});
port.onDisconnect.addListener(function() {
console.log("Disconnected");
});
任何方式,我可以調試程序?
查看http://stackoverflow.com/questions/18134665/how-to-send-message-from-native-app-to-chrome-extension/19866346 – vaughan