otm:ordering_of_messages:discard_late

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
otm:ordering_of_messages:discard_late [2011/01/10 13:17]
aspectscript
otm:ordering_of_messages:discard_late [2011/06/27 08:34] (current)
aspectscript
Line 1: Line 1:
-Web applications typically update data from servers (//eg.// whether, time, animations, dollar rates).  Developers have to overcome the issue of using obsolete data due to a late response of a server. For example, consider a website that shows an animation (rotation of the Earth) using several ajax requests. If responses of ajax requests are retrieved in wrong order, the animation cannot be observed correctly. A solution could be to wait for all frames of the animation, however, this solution could delay to much the animation. A better solution is to discard the late frames to show the animation. The **DiscardLate** strategy discards the late responses of ajax requests (obsolete responses).+====== The Discard Late Strategy ======
  
-When the activate order is clicked, the animation always is showed a correct flow (right to left). When the deactivate order is clicked, the animation is showed a random flow. +Web applications typically update data from servers (//eg.// whether, time, streaming media, dollar rates, thread posts). Developers have to overcome the issue of using obsolete data due to a late response of a server. For example, consider a website that shows an [[http://en.wikipedia.org/wiki/Streaming_media|streaming media]] using several Ajax requests. If server responses of Ajax requests are retrieved in wrong order, the streaming media cannot be observed correctly. A solution could be to wait for all frames, however, this solution could delay to much the streaming media. A better solution is to discard the late frames (//a.k.a// frame skip) to show the streaming media. The **DiscardLate** strategy discards the late server responses. As an example, we present below a streaming media about a fight (the streaming media is finite by simplicity). This example shows the effects that reproduce in a streaming media when frames are retrieved in a random order.   
 + 
 +When the "activate order" button is clicked, the streaming media is shown in the correct flow. When the "deactivate order" button is clicked, the streaming media is shown a random flow. **NOTE:** Please first watch the application without clicking the "activate order" button to appreciate clearly the aforementioned issue
  
 The implementation follows:  The implementation follows: 
 <html> <html>
-   <link href="/aspectscript/external/otm/paperExample-SPE/order/style.css" rel="stylesheet" type="text/css"/> +   <link href="/aspectscript/external/otm/paperExample-SPE/style.css" rel="stylesheet" type="text/css"/> 
-  <script type="text/javascript" language="javascript" src="/aspectscript/external/otm/paperExample-SPE/order/lib.js"> </script> +  <script type="text/javascript" language="javascript" src="/aspectscript/external/otm/paperExample-SPE/lib.js"> </script> 
-   <iframe id="example" src="/aspectscript/external/otm/paperExample-SPE/order/discardLate" width="810" height="250"></iframe>    +   <iframe id="example" src="/aspectscript/external/otm/paperExample-SPE/order/discardLate" width="810" height="325"></iframe>    
     <iframe id="code" style="display:none" src="/aspectscript/external/otm/paperExample-SPE/order/discardLate/script.js" width="810" height="470"></iframe>     <iframe id="code" style="display:none" src="/aspectscript/external/otm/paperExample-SPE/order/discardLate/script.js" width="810" height="470"></iframe>
    <a id="button" class="button" onclick="toggle('code','example')"> <span>Toggle between the code and example </span></a>    <a id="button" class="button" onclick="toggle('code','example')"> <span>Toggle between the code and example </span></a>
 </html> </html>
  
-The DiscardLate strategy is implemented how TM advice, which is a JavaScript function, that is executed every time a response of ajax request is retrieved+The Discard Late strategy is implemented as piece of advice, which is a JavaScript function, that is executed every time a server response from //getstreamingvideo.com// is received
  
 <code javascript> <code javascript>
-var discardLate = function(jp) { +var discardLate = function(jp ,env) { 
-  if(!this.isLate(jp)){     //is obsolete this join point?+  var request = jp.target ; 
 +  if (this.idServerRespExpected <= request.idServerResp) {
     jp.proceed();     jp.proceed();
-    this.updateCr(jp); //notifies that join point was executed.+    this.idServerRespExpected = request.idServerResp + 1;
   }   }
-}+}
 + 
 +WeCa.deployStrategy (discardLate, function(jp) { 
 +  var request = jp.target ; 
 +  return request.url == ”http://getstreamingvideo.com” ; 
 +});
 </code> </code>
  
-Go back the [[http://pleiad.cl/aspectscript/otm/ordering_of_messages|the parent page]] web page.+Go back the [[otm/ordering_of_messages| parent Web page]].
  • otm/ordering_of_messages/discard_late.1294665459.txt.gz
  • Last modified: 2011/01/10 13:17
  • by aspectscript