CHAPTER 8 (Web hosting companies) PERSISTENT COMMUNICATIONS PATTERN 245 function

CHAPTER 8 PERSISTENT COMMUNICATIONS PATTERN 245 function ClientCommunicator() { this.server2Client = new Asynchronous(); this.baseURL = null; this._delegated = null; this.username = null; this.password = null; this.listen = null; this.doLoop = false; this.callDelay = 500; this.preferredTypes = “text/xml”; this.index = this.instanceCount.counter; this.instances[ this.index] = this; this.instanceCount.counter ++; this.versionTracker = 0; } function PrivateLoop(index) { var tempReference = ClientCommunicator.prototype.instances[ index]; tempReference.server2Client.openCallback = function(xmlhttp) { xmlhttp.setRequestHeader(”Accept”, tempReference.preferredTypes); xmlhttp.setRequestHeader(”X-Version-ID”, tempReference.versionTracker); } tempReference.server2Client.complete = function(status, statusText, responseText, responseXML) { if(status == 200) { tempReference.versionTracker = tempReference.server2Client.getResponseHeader(”X-Version-ID”); if(tempReference.listen != null) { tempReference.listen(status, statusText, responseText, responseXML); } } if(tempReference.doLoop) { window.setTimeout(”PrivateLoop(” + tempReference.index + “)”, tempReference.callDelay); } } tempReference.server2Client.username = tempReference.username; tempReference.server2Client.password = tempReference.password; tempReference.server2Client.get(tempReference.baseURL); } The bolded code introduces the property versionTracker, which contains the value stored in the HTTP header X-Version-ID and is the version number of the server-side state. Whenever a request is made to the server, the HTTP header X-Version-ID is added to the request and extracted from the response. On the server side, the modified GlobalStatus.doGet implementation would be as follows:
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Leave a Reply