0
我试图在Google App Engine(Python)上运行我的后端服务器来实现频道,但我不确定如何编写Chrome的前端代码。我发现了一些代码,但无法测试,因为我正在等待后端代码由我的合作伙伴编写。我想知道如果我正确实施这一点。Chrome扩展 - 实施频道
我也不明白如何触发代码?什么触发了这个频道被创建?
//The code I found which is placed in background.html:
chrome.extension.onRequest.addListener (function(request, sender, sendResponse) {
var channel = new goog.appengine.Channel(channelToken);
var socket = channel.open()
socket.onopen = function() {
// Do stuff right after opening a channel
}
socket.onmessage = function(evt) {
// Do more cool stuff when a channel message comes in
}
});
哦,我现在明白了。没有onRequest.addListener()就更有意义了。所以我的套接字将不断地收听来自频道的消息。 – Jon 2012-03-26 00:02:12