2014-02-22 58 views
1

我是开发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"); 
}); 

任何方式,我可以调试程序?

+0

查看http://stackoverflow.com/questions/18134665/how-to-send-message-from-native-app-to-chrome-extension/19866346 – vaughan

回答

0

有多种方式来调试,但没有端到端的IDE像调试存在。

  1. 调试你的背景和内容脚本---在Chrome工具

  2. 背景和页面内容部分调试主机---开放Chrome与记录终端启用

  3. 本地消息传递API还为您提供一些方法,可以返回相应的错误消息,如runtime.lastError

    can refer this