Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
otm:ordering_of_messages:discard_early [2011/01/12 08:51] aspectscript |
otm:ordering_of_messages:discard_early [2012/02/06 22:49] (current) aspectscript |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Web applications typically update data from servers (//eg.// whether, time, streaming media, dollar rates, thread posts). | + | ====== |
- | When the " | + | Another issue in the visualization arises due to the processing of early server responses. For example, consider a forum Web page that is frequently updated with threads from a server using Ajax, //i.e.// this Web page only increases with more threads that are located on the |
+ | top. Every thread is shown with its title and its first posts, and the reader can click on a button "read more" to see the whole discussion of a given thread. Every post that is below the thread title is loaded dynamically using an independent Ajax request. If server responses, which contain the posts, are retrieved and displayed in an incorrect order, the beginning of the discussion of the thread could be misunderstood. A solution could be to wait for all late posts of every thread. However, this solution could seriously delay the updating of the forum Web page. A better solution is to discard the early posts in order to correctly show the first posts of the | ||
+ | thread. The discarded posts can be fetched later when the reader clicks the given "read more" button((In this toy Web application, | ||
+ | |||
+ | By simplicity, this example shows the first posts of only one thread. | ||
The implementation follows: | The implementation follows: | ||
Line 12: | Line 16: | ||
</ | </ | ||
- | The DiscardEarly | + | The Discard Early strategy is implemented as a piece of advice, which is a JavaScript function, that is executed every time a server |
<code javascript> | <code javascript> | ||
Line 18: | Line 22: | ||
if(!this.isEarly(jp)){ | if(!this.isEarly(jp)){ | ||
jp.proceed(); | jp.proceed(); | ||
- | | + | this.idServerRespExpected = request.idServerResp + 1; |
} | } | ||
} | } | ||
+ | |||
+ | var discardEarlyCallback = function(callback) { | ||
+ | return function(jp, | ||
+ | //invoke the discard Early strategy | ||
+ | |||
+ | var request = jp.target; | ||
+ | //Is it discarded? | ||
+ | if (this.idServerRespExpected < request.idServerResp) | ||
+ | | ||
+ | } | ||
+ | }; | ||
</ | </ | ||
- | Go back the [[otm/ | + | Go back [[otm/ |