0

I'm facing a problem that is blowing my mind. I need to interface an external device into my html5 web app but I don't know how to do that. Unfortunately the only way to communicate with this device is by using the dll provided by the vendor (that can iteract with the device via ethernet itself). I know that a way to do that is by implementing for example an asp webservice client-side but I'd like to not develop another "application"; is there a way to do that directly from my web page?

Thanks you all, Regards.

EDIT: My webapp is a retail frontend html5 app written using jquery than runs only on chrome (because of offline caching/websql database). Users, when requested, need to send data to an external device connected (credit card payment system) and receive the answer: the only way to communicate is by using the vendor dll.

Elia P.
  • 3
  • 3
  • Web applications cannot directly interface with DLL files or hardware devices. You would need to have an app installed on the client machine. – TidyDev Oct 20 '17 at 22:01
  • Is your "web app" bound to be executed in a typical browser served from a webserver? if yes the answer is totally different to if you say no... – Harry Oct 20 '17 at 22:02

1 Answers1

0

I can imagine a few different ways to get to your goal:

ActiveX and NPAPI plugin are mentioned here - those are very outdated, you dont need to even open that link

[Outdated Answer] Call DLL methods from Javascript

Some collection of other methods:

[Firefox related] How to call user32.dll methods from javascript

[Newer Answer] Call Function from DLL loaded in front-end javascript (load dll in clientside javascript)

[IE only - ActiveX] https://msdn.microsoft.com/de-de/library/7sw4ddf8(v=vs.94).aspx

And last but not least my favourite and state-of-the-art method: develop a locally running System Tray app or windows service that listens on a port, allowing Cross domain calls and triggers stuff when called using ajax from javascript.

[EDIT]This last option is also cross-platform compatible and pretty portable. For explaination, this "on the client running" windows service could listen on 127.0.0.1:1234 and should just add Access-Control-Allow-Origin:* to any response that it sends, this way you can just use ajax calls to 127.0.0.1:1234 for calling it. You package and distribute it in a downloadable installer package. In your javascript you do a test api call at initialisation to see if the package is installed and available. If not, you present the download link. If running as tasktray app, you additionally provide an "i already have it, just start it" button and register an app handler in the registry (thats another topic)

In the end if you do not want to go for any kind of compiled application, the number of options fade quickly and you'd need to explain much more around why you want to use javascript only (e.g. is it just because you dont know any other language or so)

Harry
  • 1,233
  • 10
  • 24
  • Thanks for your precious answer Harry! The reason why I'd like to don't have other compiled application is because the webapp I developed (that runs only on chrome) is a FrontEnd application installed on hundreds of computers and it will be difficult to maintain another development line. Developing a system tray app or windows service should be a nice compromise (a client-side web service is really out of considering for me because of IIS etc...; a windows service is more flexible and easier), but how can I communicate between both of them? Sockets over html5 seem to be not used anymore. – Elia P. Oct 20 '17 at 22:48
  • Yeah, i wouldnt use websockets too. Ajax does the job just fine. What i do in my receiving tasktray application is to listen for new connections on a fixed high port using this example here https://www.codeproject.com/Articles/17071/Sample-HTTP-Server-Skeleton-in-C. Then i just added Access-Control-Allow-Origin:"*" to each and every response that i send and voila, ajax is able to send and receive stuff from my service. – Harry Oct 20 '17 at 23:04
  • Thank you so much Harry, I didn't know about the chance to implement a kind of http server within a windows service, that will surely do the job for me! Inside my frontEnd app I will easily check if the service is installed/running and provide a "Download service installer". Thanks for the sample code, thumbs up! – Elia P. Oct 22 '17 at 00:58