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:fifo [2011/01/07 15:38] aspectscript |
otm:ordering_of_messages:fifo [2012/02/06 21:16] (current) aspectscript |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Every day, [[http:// | + | ====== |
- | When the **activate order** is clicked, the web page always | + | A mashup application is created from the combination of information retrieved from different servers, //e.g.// Housing Maps. Programmers have to overcome the issue of creating an incorrect Web page due to an arbitrary (and unexpected) order of server responses. For instance, consider a Web page that is created with two Ajax requests. If the second server response is processed before the first server response, the Web page is created incorrectly. A **FIFO** strategy, which processes the server responses in the same order as the Ajax requests are sent, ensures that the Web page is always created correctly. |
+ | |||
+ | When the " | ||
< | < | ||
- | < | + | < |
- | <script type=" | + | |
< | < | ||
<iframe id=" | <iframe id=" | ||
Line 11: | Line 13: | ||
</ | </ | ||
- | The implementation of the Fifo strategy is: | + | The FIFO strategy is implemented as a piece of advice, which is a JavaScript function, that is executed every time a server response is received: |
<code javascript> | <code javascript> | ||
- | var fifo = function(jp){ | + | var FIFO = function(jp){ |
- | if(this.isEarly(jp)){ | + | var request = jp.target; |
- | this.queue.push(jp); | + | if (this.idServerRespExpected != request.idServerResp){ |
- | } | + | this.jpsQueue.push(jp); |
- | else{ | + | } |
- | jp.proceed(); | + | else{ |
- | this.updateCr(jp); | + | jp.proceed(); |
- | this.queue.executeEarlyJPs(); | + | this.idServerRespExpected = request.idServerResp + 1; |
- | } | + | // executing jp proceeds that can be executed now |
- | }; | + | this.idServerRespExpected =this.jpsQueue.execRecEarlyJPs(this.idServerRespExpected); |
+ | } | ||
+ | } | ||
</ | </ | ||
+ | |||
+ | Go back the [[otm/ |