Skip to content

Commit 5568eda

Browse files
committed
update api to runtime.onmessage
1 parent 51b7858 commit 5568eda

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Chrome/Example/simple_extension/bridgeClientChrome.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//bridge
1313
var bridge = {};
1414

15-
chrome.extension.onMessage.addListener(
15+
chrome.runtime.onMessage.addListener(
1616
function(message, sender, sendResponse){
1717
_dispatchMessage(message,sendResponse);
1818
});
@@ -23,15 +23,15 @@
2323
function _send(msg,responseCallback){
2424
assert(!responseCallback || responseCallback instanceof Function,"responseCallback should be function");
2525
if(responseCallback){
26-
chrome.extension.sendMessage(msg,responseCallback)
26+
chrome.runtime.sendMessage(msg,responseCallback)
2727
}else{
28-
chrome.extension.sendMessage(msg)
28+
chrome.runtime.sendMessage(msg)
2929
}
3030
}
3131
bridge.init=function(onMessageCallback){
3232
_messageHandler=onMessageCallback;
3333
//register for accept message
34-
chrome.extension.sendMessage(MSG_REGISTER_WANJUAN_INTERFACE);
34+
chrome.runtime.sendMessage(MSG_REGISTER_WANJUAN_INTERFACE);
3535
}
3636

3737
bridge.registerHandler=function(handlerName, handler) {

Chrome/Example/simple_extension/bridgeServerChrome.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
var messageHandlers = {};
1414
var _messageHandler;
1515

16-
chrome.extension.onMessage.addListener(
16+
chrome.runtime.onMessage.addListener(
1717
function(message, sender, sendResponse){
18+
if(register(message,sender,sendResponse))return;
1819
_dispatchMessage(message,sendResponse);
1920
});
2021

@@ -58,7 +59,8 @@
5859
if(MSG_REGISTER_WANJUAN_INTERFACE==message && !bridge.tabIds[sender.tab]){
5960
bridge.tabIds[sender.tab.id]=sender.tab.id;
6061
console.log("regiseter:"+sender.tab.id);
62+
return true;
6163
}
6264
}
63-
chrome.extension.onMessage.addListener(register);
65+
//chrome.extension.onMessage.addListener(register);
6466

0 commit comments

Comments
 (0)