jnlp communication with javascript - javascript

I have a JNLP application that I launch from a HTML/CSS/JS webpage. When the JNLP application reaches a specific point of it's execution, I want to update the information in my webpage.
Is there any good method of communicating with JavaScript during runtime of the JNLP application? For instance to send a message that tells the JavaScript to update/send an ajax request/etc.

I had pretty much the same requirement for my application, and I implemented it with a Comet communication.
Basically your JavaScript should connect to a generated channel per user, and listen to messages on it. Then your Java application, once launched, should open a connection to this channel and broadcast a "I'm ready" message, that the JavaScript application will receive, and then act accordingly.
Good luck, it's not that easy :) More details on http://cometd.org/

Related

Events from Local MS office application to browser

We have a content management solution and we host files.
Our server side act as a MS WEBDAV server .
Our browser side java script based application shows the files stored in our servers.
Whenever an user click on a document in our browser application , we form the ms office URIs and Local ms office installation opens. Thereafter the DAV communication happens between the local office application and our server side.
Now i want to share some information/state between the local office application and the client side browser which actually helped to open the file.
Is it possible on the browser side to listen to some events generated by office application for e.g. on save ?
Office generates event on save but they remain on the realm of Office products. How to propagate this event to the browser application running ?
I can probably develop a VSTO add in , capture the event, wrap the event to a messsage bus and let my browser application listen to that message bus but this seems pretty complex.
Also i don't have the option to send any notification from my server side to client side .
Best Regards,
Saurav
Your best bet is to create a VSTO add-in that talks directly with a server-side service.
You have a few options on how to implement this. I would try to create a WebSocket bridge, which forwards messages between the VSTO add-in and your web application client-side code. I would start by looking at using something like websockify.
Alternatively, you could create a simple HTTP web service that can be called by both parties and then have the javascript code poll for updates periodically.
Or you could even go for a hybrid of these two options, where the VSTO add-in uses a standard HTTP service call and your javascript uses WebSockets to receive updates from the same service.
This new service could easily sit alongside your main web application. Maybe, the web methods could just be part of your web application.
It is quite straight forward... You just need to figure out how you are going to keep a reference of the document so that both parties can refer to it, unmistakenly. I would consider using a file property or document metadata property.

Having a web application listen for data without a server

For my job, I am researching a new means of accessing data from a web application created in either HTML or Javascript. The situation is that we have a proxy that takes data from a computer's serial port and broadcasts it as regular TCP data on the Local Host. We have web application that runs on the local system and we want it receive that data that is being broadcasted, however we want to implement this without creating a server to acquire said data.
So far I have been researching and googling for a solution but my search hasn't been fruitful. If there exists a means for a web application to acquire data being broadcasted from a proxy, I would like to know. Also we are running the web application locally from file:\ in IE11.
This stack overflow question is somewhat similar to our situation, however we cannot use Flash or Adobe Air: AS3 socket class connection with serproxy and sending data 

Is this WebSockets approach correct?

I want to create this routine:
I access the /receiver (Receiver)
Receiver is listening for 'hello' event
I access the /emitter (Emitter) from another tab
Emitter fires the 'hello' event
Receiver says alert("Hello world") when 'hello' event is fired
Is it possible using WebSockets? I want to make the API server with Python, and the client with JavaScript.
webSockets connect client and server. The do not directly connect two web pages in two different tabs.
It is possible that two web pages in two different tabs could each connect to the server and the server could then route messages sent from one web page to the other web page. That's how a typical chat program works (which is a classic demo app for webSockets).
Yes, this is possible to build with a server in Python and client in Javascript web page.
You can certainly find many libraries written for webSockets in Python with your own search. Browser Javascript already has webSocket support built in. Many people choose to use socket.io which is a higher-level library built on top of webSocket and there are implementations for socket.io in many languages (including Javascript for the browser and Python for the server).
WebSocket is used when you need a persistent, web-friendly connection with or without a browser. If you just need to merely communicate among tabs in the same browser instance, you can use localStorage (which fires an StorageEvent event) even if you are offline.
If you potentially need the emitter to be accessed by another browser out on the web, or if the emitter was not a browser web-app (e.g., an IoT use case), then you would need WebSocket. Then one good solution would be a simple publish/subscribe mechanism using WebSocket. Here's a good Angular library that a colleague wrote that might help you:
https://github.com/kaazing/tutorials
Full disclosure: I work for Kaazing

send command via tcp ip through javascript

I want to achieve following functionality and need the help for the same:
I have one server on which there is device connected that prints some bar codes based on pre-formatted command given to it.
Currently there is one desktop application which generates the command and does the job.
Now I want to do this via web, meaning there will be one webpage (say .aspx) and I want to achieve this by javascript.
I am able to generate the pre-formatted command required for printing but I don't know how to send the command to server, whether socket tcp ip or something else.
I have tried using node.js, socket.io, json-socket etc. but nothing is working,
If javascript is a fixed requirement, then no I don't think you'll find a direct solution. You will need to create an intermediary service that will translate websocket protocol to the tcp/ip protocol your software communicates on. I found a package called Websockify that has implementations of this kind of bridge in a few different languages.
Although if you are open to using Flash on the front end, and can meet the security requirements on your backend connection, then Flash socket API could work. I believe Java applets can also manage this.
I don't believe this is possible to do from inside a web browser. If it were it would be a huge security vulnerability (think about it, you visit an attackers page and all of a sudden your printer starts printing and every shared directory on your network fills to the brim with junk data).
You could run the command on the server (node/.net/anything else...) and have the web platform talk to the server to kick the process off. But that sounds kind of like what you already have set up...
Alternately, if you can change the software on the connected device you could try to give it an HTTP endpoint which responds to POSTs.

Android running browser ASP page that sends commands to windows PC

I am wondering how i can send a command (like 1, 2, 3..etc) from my web app (classic asp/asp.net) web page on my android web browser to a windows computer thats on the same LAN network. Kind of like an instant messenger type of thing so that i can design a web page with buttons and each button would send a command back to the computer.
Is that possible? Or do you know any other alternatives to accomplish this same task?
David
If you are looking at using a web server for each system windows system, then the android app simply calls some webpage with the message. The android app would need to keep calling a particular page for 'new' messages using an ajax request. However there are probably other better was of doing this - but it is possible using this method. Another option is each windows system self hosts their own WCF app which receives messages. You still need some central store to make sure all members get the messages unless they constantly poll each other.
Another alternative (and doesn't require polling) is to utilize sockets and simply stream the data back and forth over a port and keep the connection open.

Categories

Resources