Reputation: 574
Well my question is pretty much like Proper way to listen as TCP server in Chrome extension
But the problem is that the question above was not properly answered, and the questions persists.
So, is there a way to make a Chrome App interact with a Chrome extension. The purposes are much like the question referenced above, in resume It's for building a TCP Server and manage content in a tab web page.
Well as far as I know there's no way of doing that, because Chrome App does not have access to a web page content and a Chrome Extensions are not allowed to use sockets.
So any ideas are welcome. Thanks in advance.
Upvotes: 0
Views: 218
Reputation: 77482
Despite being called "cross-extension messaging", it works between extensions and apps.
Presumably, you'll want long-lived connections; then you can use:
// In one app/extension that initiates the connection
// (Probably the app upon a new client connecting)
var port = chrome.runtime.connect(secondID);
// In other app/extension
chrome.runtime.onConnectExternal.addListener(function(port) {
port.onMessage.addListener(function(msg) {
// See other examples for sample onMessage handlers.
});
});
Remember that you want to make sure the connection comes from something you trust. While an imperfect defense, you should check the originator's extension/app ID - whether in your code or by filtering the rest out with externally_connectable
manifest key (default is permissive).
Upvotes: 1