Both sides previous revision
Previous revision
Next revision
|
Previous revision
|
otm:ordering_of_messages:discard_late [2011/06/27 08:28] aspectscript |
otm:ordering_of_messages:discard_late [2011/06/27 08:34] (current) aspectscript |
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 ====== |
| |
| 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. | 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. |
</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 ,env) { | var discardLate = function(jp ,env) { |
var request = jp . target ; | var request = jp.target ; |
if (this.idServerRespExpected <= request.idServerResp) { | if (this.idServerRespExpected <= request.idServerResp) { |
jp.proceed() ; | jp.proceed(); |
this.idServerRespExpected = request.idServerResp + 1; | this.idServerRespExpected = request.idServerResp + 1; |
} | } |
WeCa.deployStrategy (discardLate, function(jp) { | WeCa.deployStrategy (discardLate, function(jp) { |
var request = jp.target ; | var request = jp.target ; |
return request.url == ”http://news.com” ; | 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]]. |