Is there a way to call an external program on client side and "talk" to it?
For example, if I have a Node.js serverving an AngularJS or any other framework, I want the user to press a button on the browser and a previously installed program on client-side starts to run and send back to the client some messages...
Can I achieve that?
Is there a way to call an external program on client side and "talk" to it?
For example, if I have a Node.js serverving an AngularJS or any other framework, I want the user to press a button on the browser and a previously installed program on client-side starts to run and send back to the client some messages...
Can I achieve that?
Share Improve this question asked Nov 23, 2015 at 14:24 felipefssfelipefss 1291 silver badge9 bronze badges 6- You can if you also code the client-side application and an extension/plugin for the browser used by the user to make your webapp talk with the desktop application. – Shanoor Commented Nov 23, 2015 at 14:26
-
2
One way to do something like that would be via a custom protocol link that is set up when the application is installed. For example, you can launch the steam friends window via a link like so
steam://friends
. The user has to allow this action. As far as running an arbitrary executable on the users' machine, no that is not possible (nor secure). – CollinD Commented Nov 23, 2015 at 14:28 -
I would consider a bination of socket.io and the node process
require('child_process').exec
. The latter has event emitters that you could easily wire up to the socket to track progress of the native executible – Joe Commented Nov 23, 2015 at 14:41 - @ShanShan I was actually wanting to run away from extensions for their instabilities... – felipefss Commented Nov 23, 2015 at 14:46
- @Joe I thought of that, but then the process would run in the server side, wouldn't it? It'd just be called by the client. I want the process to run on client side puter. Like a C++ application. – felipefss Commented Nov 23, 2015 at 14:47
4 Answers
Reset to default 4Browsers cannot run executables on the local machine without explicit configuration as such behaviour would violate security restrictions.
Node.js can do anything that is permitted by the environment (e.g user permissions) in which it is run. See: https://nodejs/api/child_process.html#child_process_child_process_exec_mand_options_callback
Consider using Native Client
Native Client is a sandbox for running piled C and C++ code in the browser efficiently and securely, independent of the user’s operating system. Portable Native Client extends that technology with architecture independence, letting developers pile their code once to run in any website and on any architecture with ahead-of-time (AOT) translation.
In short, Native Client brings the performance and low-level control of native code to modern web browsers, without sacrificing the security and portability of the web.
https://developer.chrome./native-client
This is certainty possible in many different ways.
One sort is using node webkit.
Another,a NPM package called Edge. This is sort of like a bridge between node a . Or more specifically node and a clr process. You can execute c# statements and load assemblies in a clr process and interact with it in javascript via node and Edge.
https://github./tjanczuk/edge
I think that the better form to do that is using API REST, you can create your server API in node JS for example and use AngularJS to consume that services in the browser and JAVA or .NET for the Desktop app
the following is a simple Example using Node and Angular