Real time page updates using XML-RPC, javascript, php
I am developing a rich-client application, where the user-interface is html/css/javascript (codeigniter framework), and the server portion is written in Java. Essentially, this is a monitor / control system where a user can issue a command via the ui, and the backend will carry out that request.
Currently, RPC is done over XML-RPC. Sending requests, and receiving responses is working very well. However, my latest issue involves real-time ui updates.
The server receives real-time updates from whatever it's monitoring, and I need to reflect those changes 开发者_如何学Cin the ui, immediately. Currently, we use a XMLHttpRequest to long poll the database for any changes, and then update the ui. Obviously, this has many disadvantages, immediacy being the main concern.
How about using XML-RPC to open a request, and only respond when there has been an update (of interest). Once that occurs, update the ui, and open another request; repeat. However, I am unsure of how this might be implemented, since I do not believe you can call a JavaScript function from a Controller in Codeigniter (in my mind, this is essential, how else can I update the page elements after they've initially been loaded).
I'd appreciate any suggestions.
Edit: I've read about the comet technique, and web sockets, and unfortunately web sockets is not realistic for this project. Comet is more or less what I am suggesting in regards to using xml-rpc and a long, open request. So, please, any suggestions are welcome OTHER THAN comet and web sockets.
Check out Comet.
精彩评论