I have been using XMLHttpRequest at work on an internal tool. It is very fast and handy. One system, that I could see developing out of this, is a generic message bus. Instead of having each UI element check for changes back on the server, it would be nice if they could register interest and only request new data when they are told of a change. Perhaps a callback function would be passed in when registering. The next question is how stateful is this bus? Can it work across all user's regardless of the state, or does some state need to be maintained, such as which messages have they received. Should this state be maintained client or server side?
The client side bus piece would be the one item frequently polling the server side application. Upon a change, an object could notify it's listeners that there was a change. A unique change id would be created. During the next X amount of time, whenever polled, it would include a very brief change element such as <change id="uniqueid" model="testMatrices">. This timed method removes a per client state, but will fail for connections that are slower than this X time threshold.
The first time a client polls and gets this data, it would cache the id and then call the registered functions for testMatrices, such as reloading data from a listMatrices resource. Subsequent polls where testMatrices had changed could be ingnored until a new id attribute value is encountered.
The client side bus piece would be the one item frequently polling the server side application. Upon a change, an object could notify it's listeners that there was a change. A unique change id would be created. During the next X amount of time, whenever polled, it would include a very brief change element such as <change id="uniqueid" model="testMatrices">. This timed method removes a per client state, but will fail for connections that are slower than this X time threshold.
The first time a client polls and gets this data, it would cache the id and then call the registered functions for testMatrices, such as reloading data from a listMatrices resource. Subsequent polls where testMatrices had changed could be ingnored until a new id attribute value is encountered.

0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home