Interaction between browser and external hardware? - sockets

I'd like to know what are the different ways for a browser to interact with external hardware.
Something important : I have control over the machine. That means I can install addons( firefox, chrome ), and run exes on the machine.
I already have a JAVA program that can communicate with the hardware, and I'd like to know how to expose the interface to the browser. So that's one possibility I'm investigating but I'd like to know if there is any other way I can do it.
Thank you

I had a similar problem. The only ways presented were to either use an addon, or write use a tiny C server that uses HTML as it's GUI.
I know you are using Java, and this thread is C++ related, but the basic principles should still work: link here.

You can expose a COM interface from your java application and use silverlight to talk to it. This is significantly simpler if the desktop application is in .NET. Check out: http://www.wintellect.com/CS/blogs/jprosise/archive/2009/12/14/silverlight-4-s-new-com-automation-support.aspx

HTML5 will have a device element that will allow you to connect external devices. Right now, the only choice you have is using plugins to communicate to external hardware.
You can search about NPAPI (a new api called PPAPI is in the making) that will allow you to create a plugin that communicates to native code to do whatever you want.

Related

Flutter and IBM as400

a particular question: is there a direct way to make an AS400 connection or do you have to go through PHP? I don't have to read data on DB2, but do the various commands (wrkactjob, wrksyssts, etc.). Thank you.... sorry for the English.
what I thought (maybe it can't be done) is this: in the app screen there are buttons, each button executes a command (wrkactjob, clroutq, etc.) and the answer occurs in another screen ... I didn't want to write commands directly like on 5250 or telnet
From your referral to typical "health checking" programs, like wrkactjob, and wrksyssts I guess your primary goal is to have an application running on your Android based phone to quickly check the status of a machine from wherever you are. Correct?
Have you considered how to get access to the machine's IP address when you're on the road and not connected to the local WiFi?
You can access this "performance data" through SQL — as John Y pointed out — and display it in whatever for is convenient on your mobile device. But I highly doubt Android provides ODBC infrastructure, even though you might manage to get the correct binary blobs (CPU wise) of the ODBC drivers from IBM botched into Android.
Otherwise you want to create a mechanism to scrape the screen for whatever is displayed, and translate that textual representation into UI elements provided by Flutter, if you want UI elements instead of textual output.
If you already have your doubts that you can't do telnet with Flutter, I think you'll have to learn a lot about Flutter as an SDK before even thinking about how to start developing an application. TCP/IP networking services are a function of the underlying OS and you'll have to go through all the Flutter abstraction layers to eventually be able to build a TCP session. With some luck, there is already code available to handle the telnet protocol peculiarities for you. Perhaps not, then you need to provide telnet negotiation and protocol yourself. This is documented in numerous RFCs. Use Google yourself.
Next point is: You need to establish translation routines for conversion of EBCDIC charset data into ASCII. Because Android is Linux based, you need to learn how to call libc routines like iconv() through Flutter, providing a C interface for charset conversion, including EBCDIC flavors as source/target.
Final point: You need to learn how to interpret the 5250 data stream, and translate the terminal emulator instructions into dynamically place Flutter UI elements at appropriate positions on screen. And of course you need to understand what to send back to IBM i to make it understand your request. The tn5250 data stream is also documented in publicly available RFCs.
There once was a facility called Workstation Gateway in the OS, but as I've found out, it has been removed in V5R2. This might have provided an easier means, because the 5250 data stream was converted on the fly to plain HTML.
Now it's your turn to decide if your goal is worth the apparent effort you're required to go through.
I am not sure what you mean by "direct". Do you mean doing your own socket programming? You could, but there are easier ways to connect.
The most obvious and straightforward choices are probably ODBC, JDBC, HTTP, and SSH.
ODBC and JDBC of course provide an SQL-based interface, and you can use that to issue commands (via the QCMDEXC procedure or scalar function) or access an increasingly comprehensive array of IBM i services.
If what you need still isn't available via SQL, or you simply don't like working in SQL, you could make use of the XMLSERVICE library, which provides its own programming interface "on top of" any of the connection types mentioned above. Despite all the instructions for building from source, normally this should already be installed on your IBM i. There are higher-level wrappers for XMLSERVICE in several programming languages (.NET, Node.js, PHP, Python, Ruby, and Swift), but as of this writing, not Dart. I am not familiar with Flutter, but I imagine you could use the JavaScript interop package to work with the Node.js wrapper.

Can I use webassembly for plugins like blender uses python?

I was talking to a friend of mine who knows a lot about js and wasm.He told me the technology goes far beyond web, since it is basicly a way to run near native applications on devices without actually giving them access to the computer.
Which means that thrid party or untrusted code on a smartphone for instance cannot accidentally or intentional change other apps or parts of the system.
This seamed to me like the perfect conditions to build a plugin system for an application I am working on.
I asked him about it but he was unable to give me a clear answer.
So the question is, can I use webassembly outside of a webbrowser, with custom bindings to safely allow users to extend the functionality of my application (a special image viewer) without sacrificing too much speed? It seams it should work using libnode or something, but is there a problem I might run into?
I don't know how much you know about web assembly but it depends on what your plugins actually should do. If it basically handle Arrays and numeric data with not that match interacting with host applications then it might fit. But when you have heavy object handling then it will not fit at the moment. So for image processing it might be perfect match like it is used in some web examples. Also be aware that some web assembly targeting system or not suitable for none web targets as they generate also some javascript code to be used in browsers beside the generate wasm. Some wasm modules for example require that you call malloc and free for string handling other have functions like new and gc for the nearly the same.

Building a professional application in Perl?

I've built a set of tools I use in my day-to-day work and I would like to make them look a bit more "professional" in order to sell them to financial institutions.
At the moment these tools are written in Perl and are executed from a DOS command line, it's extremely efficient but it doesn't look very attractive.
So, I would like to add a user interface to it but I don't really know what to use for language knowning that :
A Perl CGI interface hosted on the web is not an option since the information to be given as input is quite sensitive.
It would be ideal to sell it as a package/executable.
I don't really like the Perl/Tk interface.
I'm ok with rewritting the application in another language but I would prefere to reuse the main modules in Perl since it's very powerful with regular expressions and lists/arrays.
What would you advise me to do ?
Thanks,
Lory
If you want a non-web-based GUI, and don't like Tk, there's also Wx, which is a wrapper for the wxWidgets GUI toolkit.
However, web applications nowadays can be really easy to create (using a modern framework). Take a Mojolicious application, for example: Mojolicious carries no dependencies other than Perl 5.12.x, and provides its own web server (Hypnotoad). You can start by generating a "Lite::App", which is a simple self-contained single-file application, and then grow it to a bigger distribution later on as the need arises. It even comes with tools to convert your application to a conveniently packaged distribution that can be installed as easily as any CPAN module.
So that leaves the issue of security. User authentication, IP whitelisting, local network only... there are many ways to make a web application "for internal use only" if that's what you need.
You might just throw together a web-application prototype, and once you determine customer interest in your product, invest the substantial time in writing it as a Windows GUI application.
Continuing on from DavidO's answer, because the current web microframeworks for Perl (I prefer Dancer over his suggestion of Mojolicious, but both are good and largely equivalent) contain their own bundled web mini-servers, they also allow for the app to easily run entirely on the local machine.
Since these mini-servers default to a non-standard port (usually 3000 or 5000) by default and you can easily set them to a different port, they can be isolated by firewalls relatively easily, ensuring that nobody can connect to them remotely. You can also, of course, include and IP address check in the app and have it reject any requests that don't originate from localhost.
My guess is that the target system will be Windows. Use a RAD (Rapid Application Development) platform to develop a GUI. Examples for such a platform are Delphi or .NET with C# or VB. For bundling the Perl part, consider using a tool called perl2exe.
It doesn't sound like your scripts should require a web server. Also, consider the installation hassle. Only guessing as you're not giving much information about what your scripts are doing.
I am using the Cava packager to deploy my Perl-written tools. You can even generate an installer executable with just some mouse-clicks. It works pretty well with strawberry Perl and wxPerl on Windows.

How to write an application like skype as a Browser plugin?

What technology, frameworks, programming languages are involved? Must support for tcp inbound and outbound connections, read webcam and mic data.
Browser plugins have access to the operating systems native APIs, so there is no major difference to a stand-alone application regarding camera-, audio- and network-access. What you have to be aware of though is that your code might run in a less privileged process.
For Internet Explorer you will have to write content extensions, specifically ActiveX controls, using C++. For all other browsers you will write NPAPI plugins C++ or C.
On Windows you can combine the two plugin types into one DLL. FireBreath does that, which you should look into as it already abstracts over the browsers (and other problems) for you.

Integrate Chrome with command-line tools

I'm trying to set up some integration between Chrome, and various command-line tools and build systems that I have. Almost everything that I want to do within Chrome is supported by the extensions API, so I figured I'd make an extension, set up communication between it and my external tools, and go from there.
Unfortunately, I can't find any sane way to get messages in and out of Chrome. The only thing I could find that would plausibly work at all, would be introduce a local web server as a message broker, having the extension connect to it with WebSockets, and then having the command-line utilities do the same. But that's way too much complexity - it'd basically mean writing a whole IPC framework.
Is there any reasonable way to do this?
There is currently no way to let extensions communicate outside Chrome without XHR/WebSockets/SocketAPI or any traditional methods like Image URLs, JavaScript URLs etc.
If you want make an overkill, you could try creating a NPAPI Plugin that writes protocol messages to disk/file (like how Apache WebServer does), and create another standalone Python script/or any other scripting language that tails that. So your API would basically read that file that the NPAPI Extension Plugin creates.