我是开发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