Communication between Chrome javascript and native Windows code - windows

I need to have a communication channel between my web application that runs on Chrome, and a native code on Windows. I need to run a native code when JS requests and pass the results back from native code. The environment is totally managed so I can set trusts and group policies, etc.
I can think of preparing a small web service that runs locally (and allows CORS) and call this service from javascript, but in this case i need to run this code forever.
Any advices will be very helpful. If it is possible i can try Windows registry write/read, pipes, shared memory, MMF or any other way to do it.
Thanks

There's a way to communicate with local processes without using an extension. Websockets aren't restricted to communicating with the same domain as the web page, they can communicate with a WebSocket server on localhost. You have to wrap your native code in a WebSocket server, libraries are available for that though.
Another method is Native Messaging, but it requires a browser extension:
Native messaging enables a WebExtension to exchange messages with a
native application installed on the user's computer.
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging
https://developer.chrome.com/extensions/nativeMessaging

Related

How do I know if a library is server-side or client-side library?

Correct me if I am wrong, a server side library runs on a server, and a client side library runs on the user's computer.
However, how do I know if a library runs on server or client? Is there a rule of thumb?
For example, why are node.js libraries server side libraries if you install it on your local machine and run it on your local machine?
If the library is executed somewhere locally but outside of a browser, is it still considered a client side library?
I would recommend you read these two articles. They should give you some clarity on Node.js functionality and server and client side scripting.
Server VS Client
https://skillcrush.com/2012/07/30/client-side-vs-server-side/
Intro to Node.js
https://www.google.com/amp/s/opensourceforu.com/2016/01/an-introduction-to-node-js-the-server-side-javascript/amp/

What is the capability of PWA for Windows?

I'm totally new to PWA (rather I'm still considering adopting PWA or go Electron).
Looking at the concept and guides of the app on the web, it seems that the capability of it is to this extent, thus;
Access web APIs securely and easily
Yes, as it is the alternative implementation of web apps.
Access local storage of the PC for the app
Yes, through HTML5 web storage.
Access any local files in the PC
No?
Communicate with another desktop app through TCP connection
Yes? By posting/getting some query to localhost for example?
Obtain system info like PC status or installation path of another desktop app
No?
How many of my understandings are correct? Is there another capability or limitation to be specially noted?

Can I run a http server in nativescript?

Is it possible to run an in-app HTTP server with NativeScript either as a background service or as part of the foreground app itself ? I am looking to utilize a common code base across a system of applications which would communicate to a local server which handles some parts of the application's communication to my servers. Where, I intend to create a HTTP server in the app which can just serve as a REST server for the app. Is it possible ?
Thank you.
I don't think its possible since nativescript doesn't offer any module or plugin that supports the creation of http servers. First option is to look for a nativescript module in npm that supports http server creation, Second option is to create an http server using the native API's with javascript, Third and last option (which I prefer) is to make your own server using nodejs or any server side script and run that server on a certain machine then from your nativescript app you can access that server using the fetch module or the http module :)

Internet Access Controller using .net ( vb or c# )

I want to develop a software which restricts users internet access using vb6 or vb.net.
This is not a baby sitter program but
1) whenever a client machine takes any browser it should ask for username and password.
2)There should be option for adding new users at the server side application.
can anyone suggest any name of such a software. or some sites where I can get some help
on the same..
You could implement a HTTP proxy using sockets. You would turn off internet connection sharing on your server and configure the other machines to connect to the web via your proxy.
I would recommend going for an off the self solution e.g. in a router rather than building something from scratch.
If you are dead set on using VB6 you could make use of the winsock control. Here is a project using winsock to serve files. You could modify it to become a multithreaded proxy server instead. It will be a tough challenge though.
http://www.codeproject.com/KB/IP/winsock.aspx

Online server for desktop app - implement as web-server or custom socket application?

A bit of a generic question but let's say you have a desktop app that allows a user to connect to a central server and provides functionality like:
Login
Ability to auto-download profile data on login
Download and uploading save files through the app
A web-server (JSP/ASP.NET/PHP/etc) would do lots of work for you especially on the request-serving and threading front, but it seems a bit of a cheat for a desktop app to use HTTP requests like this.
All thoughts welcome. Maybe this should be community wiki?
If you want to leave things open for other possibilities in the future, go with a web server. That way, if you decide to write a web-based version of your desktop app (or an iPhone/Pre/Android application), you don't have to rewrite your socket server. Almost everything can speak HTTP these days.

Resources