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/12 00:41]
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, 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 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 responses of ajax requests (obsolete 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.  +====== The Discard Late Strategy ======
  
-When the "activate order" button is clicked, the streaming media is always showed the correct flow of the fight. When the "deactivate order" button is clicked, the streaming media 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: 
Line 7: Line 9:
    <link href="/aspectscript/external/otm/paperExample-SPE/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/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="290"></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 as a 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 a 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 [[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.1294792894.txt.gz
  • Last modified: 2011/01/12 00:41
  • by aspectscript