Reputation: 1538
Currently we have an Applet that interacts with our hardware and server via FTP, Sockets and HTTP messages. I have been asked if we can drop the applet and just go with a browser displaying dynamic web pages and JavaScript. I don't believe this is possible as it is my understanding that a browser can only display the response to a request that it has initiated while our application needs to display data it gets from hardware that is only sent when its sensors are tripped.
I thought of using AJAX to periodically poll the hardware but I believe the same origin security restriction will prevent me from polling different hardware devices with different addresses. I could fix this by having the various hardware devices send all updates to the server but this would force a major change to the way we are currently configured. There is also a question of performance - it is a national application with hundreds of devices generating millions of events per day. I have to be able to respond in 3 seconds so I would have to poll the hardware very frequently (1 second or less) to maintain that level of performance.
So is my understanding of web applications correct?
Is there a way for a browser to display information coming from multiple addresses?
Upvotes: 0
Views: 1388
Reputation: 340743
It is possible. First of all you are right that a browser cannot directly connect to other servers using AJAX. If these other servers are actually some hardware devices, I would call this an advantage. You need a server to receive all the traffic.
However in modern browsers and servers you can use comet, web-sockets and other techniques to push data from server to client. Basically you keep an open HTTP connection on the client and whenever server has some data, it sends it immediately without any delay. This is a major improvement compared to polling every few seconds - you avoid latency and extra load on the system.
In Java land you have servlet-3.0 and atmosphere to the rescue.
Upvotes: 1