2

I would like to use the chrome browser as a software technical platform for digital signage purposes. To force the chrome browser to receive and execute any self-defined custom commands (e.g. create a new tab and inquire the content of a certain web-page/url) I need to run the chrome browser as a server listening to a certain network port.

What is the best way/technology to use websockets, server.io, etc?

abraham
  • 46,583
  • 10
  • 100
  • 152
Anton Berger
  • 39
  • 2
  • 4
  • Maybe this helps: http://stackoverflow.com/questions/4262543/what-are-good-resources-for-learning-html-5-websockets – Wouter Dorgelo Feb 26 '12 at 13:55
  • 1
    Can you rely on Chrome having network access? It would be easier to proxy requests through a websocket server that the browser and the controller both connect to rather than trying to turn Chrome into a websocket server. – abraham Feb 26 '12 at 14:37

2 Answers2

1

NPAPI is the only way to do what you want, short of drastically modifying and compiling Chromium from source. If the client that controls Chrome is in a browser, then packaging a WebSocket library as an NPAPI plugin is probably your best bet. If your client is a desktop application, packaging a plain TCP library should be sufficient.

However, NPAPI has quite a steep learning curve, so I don't recommend using it if you can help it. If possible, just have Chrome establish a constant connection to a central server (using, e.g., Socket.io). Your client can also connect to that server and use it to forward commands to the Chrome instance that you want to remotely control.

So, instead of:

[controlling client] ---> [Chrome]

You could use:

[Chrome] ---> [myserver.example.net] <--- [controlling client]

If your system requirements mandate independence from the Internet (i.e. Chrome won't always have access to a specific external server like myserver.example.net, but must still accept clients on the local network), then you could run the intermediate server on the same machine as the Chrome browser that you're controlling.

apsillers
  • 112,806
  • 17
  • 235
  • 239
  • Can't you just have [Chrome] ---> [controlling client (websocket server)] using websockets... Once the connection is open, it should be bi-directional? – Jamona Mican Apr 13 '12 at 12:56
  • Sure, that's perfectly workable as long at the controlling client is always accessible at some consistent network location known in advnace -- perhaps via dynamic DNS -- so that Chrome can always reach it. My solution is very similar to yours, involving a non-moving middle server, which permits the controlling client to move around and connect from locations that are not known in advance. – apsillers Apr 14 '12 at 03:08
0

Maybe you can implement for example Node.js via NPAPI and get it work... or something else.

It would be better if you use something else because google controls all NPAPI extensions manually.

Mattias
  • 9,211
  • 3
  • 42
  • 42
  • Thanx, Running NodeJS as the proxy server and the chrome websocket client on the same machine is a good idea. I hope it can be done with socket.io and/or websockets. It would be nice to have a 80% portable solution which probably also could be ported to Firefox. – Anton Berger Feb 26 '12 at 15:23
  • I´m not 100 sure but... If you set up Node as the proxy and write js that can talk to all the different browsers you should probably be able to use most of your code in different browser. Since NPAPI is widely supported. – Mattias Feb 26 '12 at 15:32