As stated in the title, I would like to know how to send a message to my extension installed over any computers.
I used script.js (into background_page):
chrome.extension.onConnect.addListener(function(port) {
if(port.name == 'myport')
port.onMessage.addListener(function(msg){
console.log(msg.text, msg.nick, msg.date);
port.postMessage({ backTxt:msg.text, backNick:msg.nick, backDate:msg.date });
});
});
I've created createHTMLNotification("otherpage.html")
into script.js.
Into 'otherpage.html' I have manage_msg.js.
mnage_msg.js:
"when keydow event == 'enter' " -> port.postMessage({text:text, nick:nick, date:date});
port = chrome.extension.connect({name: "myport"});
port.onMessage.addListener(function(msg) {
html = '<div class="date">'+msg.backDate+'</div><div class="nick">'+msg.backNick+'</div><div class="testo"></div>';
box_chat = new Element("div",{ class:"box", html:html });
box_chat.inject($("container_boxes"));
box_chat.getElements(".text")[0].set("text", msg.backTxt);
canISetSlider();
});
The problem is that such a message arrives only to me, the sender. Therefore, only my HTMLNotification
goes to update.
This mechanism is not designed to send messages to to other instances of your extension in other browsers - it is designed to send messages between the different contexts in your extension. If you wish to communicate with other instances of your plugin, you will probably have to use an external server, which takes messages from your computer to others' computers.