正确的方式在Chrome扩展中侦听TCP服务器 [英] Proper way to listen as TCP server in Chrome extension
问题描述
我想创建一个TCP服务器并在其上侦听。我需要访问标签内容,所以我需要一个Chrome扩展。可悲的是,只有Chrome应用程序才能创建TCP服务器。
在Chrome应用程序中创建TCP服务器并让应用程序与扩展进行通信是一种有效/这甚至有可能吗?)?
如果不是,我的选择是什么?我唯一的想法是从服务器模型更改为客户端模型,并让扩展连接到外部服务器。这个解决方案在我的情况下会很差,所以我尽量避免它。
我想要实现的是我可以构建一个chrome扩展用远程访问修改/刷新内容(无恶意)。外部程序应该能够连接到扩展程序(或:应用程序),并将它们的命令发送给它。 是它是一个好主意。
1°)您应该创建一个Chrome应用程序Web服务器(基于 https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/webserver 或其他任何HTTPs)
<2>然后你应该从任何javascripted网页通过XmlHttpRequest来请求它。
+++:无需Chrome扩展程序。应该在安装了Chrome 33+的Windows / Mac / Linux上使用任何现代浏览器。
I want to create a TCP server and listen on it. I need access to the tab content, so I need a chrome extension. Sadly, only chrome apps can create TCP servers.
Is it a valid/good concept to create a TCP server in a chrome app and let the app communicate with an extension (is this even possible?)?
If not, what would be my alternatives? The only idea I have is to change from server model to client model and let the extension connect to an external server. This solution would be poor in my situation, so I try to avoid it as best as I can.
What I want to achieve is that I can build a chrome extension that modifies/refreshes content with remote access (nothing malicious). External programs should be able to connect to the extension (or: the app) and send their commands to it.
Yes it's a good idea.
1°) You should create a Chrome App Web Server (based on https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/webserver for example, or any other HTTP s)
2°) Then you should request it from any javascripted web page via XmlHttpRequest.
+++: No need for Chrome Extension. Should work with any modern browser on Windows / Mac / Linux with Chrome 33+ installed.
这篇关于正确的方式在Chrome扩展中侦听TCP服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!