Israel Railways Gadget The user request

What is done behind the scenes while making a request

What happens when clicking "Search" in the search tab?

Well, when the user clicks "search" the gadget builds the request to the proxy.
A function that receives all the information from the form in the Search Tab process it and builds an HTTP GET request to the proxy.

The gadget takes the proxy url from the Options.xml and concatenates to it one by one the parameters the user selected and switches the gadget to the Trips Tab.

Behind the scenes when the waiting bar is shown

While the bar is shown the gadgets is mostly idle. Although it makes a big effort to get the response quickly:

  • First of all the gadgets calls to the asynchroneous function _IG_FetchXml() with the requested url.
  • _IG_FetchXml() sends the request to the proxy as an HTTP GET request and sleeps until the response is received, or until it's timeout, the first of them.
  • Because there is nothing to do while we are waiting the gadget goes sleeping also. If the response is received before _IG_FetchXml timeout it will return and the gadget will start the callback function that is passed as parameter to the fetch function. This function will do the parsing and is explained in the Trips Tab. The other parameter passed to this function is a refreshing-interval, which defines how much time the xml will reside in Google's Cache.
  • If _IG_FetchXml timeout, there is no way to the gadget to know when the response reaches. So, we developed a re-fetch engine, which works as following:
    • The gadget goes to sleep for 7 seconds (we find this as the optimal sleeping time, less time causes overhead in the proxy, more time is too much).
    • When the 7 seconds passed the gadget calls again to _IG_FetchXml with the same request. Why? Because it hopes that was an _IG_FetchXml timeout, thus it did not receive an event when the response reached. So if this is the state, the response resides in Google's Cache and now it will not go to the proxy, but the gadget will take it from the cache!
    • If the response doesn't reach we will call again the proxy. Alhough this causes overhead in the proxy (twice the same request is done) it is meaningless, since the request is probably finnishing uploading.
    • What if the Web Service does not respond? Well, after 4 tries to re-fetch the gadget gives up and shows the user that the server is busy.

Back to Development Details

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License