How to run a chrome extension as a web socket server? - google-chrome-extension

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?

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.

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.

Related

How does Rabb.it stream broswer windows for users

I am just wondering how rabbit is able to give each user a diffent broswer to use from a linux machine it seems like vnc tech but I dont know please let me know if you know how they are able to do that.
There is a somewhat detailed blog post about what their architecture was here: https://bloggeek.me/rabbit-webrtc-interview/
I will quote the relevant part for longevity:
We have two main stacks, one for audio/video and one for our business
logic:
Our audio/video stack is built in Java on top of Netty:
Our SFU allows us to use WebRTC with much larger groups than the
normal use case. For our shared viewing feature (called Rabbitcast™),
we had to build a native extension to capture and delivery an HD
stream with audio from our virtual machines. Both of them use our own
WebRTC server stack to talk to the clients. Our Business Logic stack
is built on top of Node.js using a promise-based approach to keep our
sanity.
Lastly we use Redis both for intelligent caching and pub/sub. MongoDB
is our persistent storage.
I am not sure about what exactly they are using but I have some ideas how it works yeah as you already said they are using virtual machines that ported to a html5 vnc client to control and stream video and audio. Other options might be using xpra,x2go,apache guacamole to port them into a html5 client again.

Commnication with scanner using Node js

Is it possible to to communicate with scanner using node js ?
We are using a php application which currently uses a Java applet to communicate with a scanner.
Since latest chrome versions have stopped support for applets we are looking for an alternative method for usb port communication
Can nodejs help us initiate the scan and read bufferstream from the port ?
If not what others options do we have ?
It should be possible with additional libraries.
Try to use this one https://github.com/tessel/node-usb
There is no pure javascript solution.
Fast way is to convert Java applet to Java Web Start. You have to write JNLP which download jars and runs applet outside browser.
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/applet_migration.html
You can also install scanning daemon on client side and connect via web sockets.
Eg. https://www.npmjs.com/package/scanner-js

What are the different ways you can communicate with USB port through Browser

I want to create a webpage that will access the USB port of the client. Intent is to configure the hardware connected the USB port. I can do a desktop application because the configuration option is different for different hardware. connected and I need to pull this code dynamically from the server. I am not a web programmer. It will great to find the best way to do this.
It ends up that I am attempting to write an app that performs something similar. What I am doing, instead is writing both the web server and the web page. Use something simple, like DLib for the web server, to serve the data to the end user.
This is how it works:
The web server handles the USB connection. If written in C++ or some other native language, you will have much more control over the device. The web page is then loaded from the web server that you have written. In the web page, you can have some sort of javascript worker, etc. to constantly pull new data from the server and push data from the web interface to the USB device. This also adds a layer of protection because you can ensure that the user has not made any modifications to the web page.
The main drawback to this possibility is that you will be required to install the server on the client's machine. However, this can be circumvented by writing this as a applet that can be embedded within the page!
It is possible to write a browser plugin that communicates with USB devices. An example of an app that does that is MyTrezor.com, but unfortunately I don't think you can see the source of their plugin.
Another option might be to use the chrome.usb or chrome.serial Javascript API, but this means your app would only work in Google Chrome, and it would have to be installed as a Chrome packaged app, a special thing that looks more like a native app than a web page.

can npapi do everything that ActiveX can?

I wanted to write a B/S project that client side uses ActiveX or Gecko to Communication with server via network socket. And any browser(ie/firefox/chrome/opera/safari) can use it.
If you want to support every major browser than you need to write both the ActiveX part (for IE) and the NPAPI part (for all other browsers). You can use support both technologies with one DLL though.
An easier way than implementing both yourself would be to use FireBreath, which does that for you and provides an abstraction layer over those APIs.
As you write native code with both technologies, sockets etc. can be used with both. The biggest limitations are with the UI side and permissions due to running code in a host application.
Note that XPCOM as a plugin technology is obsolete.

How will Google Native Client change the way we use Browsers?

I just came across Google Native Client
Now, it looks really interesting that they ported Quake to run on a Browser and you can run C++ code on a browser to process things more quickly, but I am trying to understand, what is the practical usage of NaCl?
What is the vision behind this by Google? To run software as a service on their "cloud" OS..err browser?
For example: Run Photosphop CS 5 on your browser?!
Anything you can do with ActiveX, but far more secure.
Elaboration:
Google Native Client allows you to run machine code locally and natively, but sandboxed insofar as only allowing access to protected memory regions and disabling exploits in the machine code relating to processor errata (certain sequences of machine code operations which act strangely on particular processors). Additionally, certain APIs are available (such as OpenGL) and there is interprocess communication with Javascript running with the page, allowing webapps which have a fast, powerful native backend.
It would be quite difficult to use the Win32 API to generate any native windows or controls with Google Native Client, whereas it'd be probably a bit easier with ActiveX. However, ActiveX is generally used with things like "Quake Live" to provide a fast, native experience for the player, and additionally for Internet Explorer 'plug-ins' -- the Flash plug-in is ActiveX, for instance, and uses native code (i.e., the plugin is compiled to machine code).

Resources