[z3-checkins] r30877 - z3/jsonserver/branch/merge/browser
reebalazs at codespeak.net
reebalazs at codespeak.net
Wed Aug 2 11:29:08 CEST 2006
Author: reebalazs
Date: Wed Aug 2 11:29:05 2006
New Revision: 30877
Modified:
z3/jsonserver/branch/merge/browser/json.js
z3/jsonserver/branch/merge/browser/requestmanager.js
Log:
Change requestmanager in favour of kss/azax
Modified: z3/jsonserver/branch/merge/browser/json.js
==============================================================================
--- z3/jsonserver/branch/merge/browser/json.js (original)
+++ z3/jsonserver/branch/merge/browser/json.js Wed Aug 2 11:29:05 2006
@@ -87,9 +87,6 @@
_DummyRequestManager.prototype.notifyServer = function(method_with_parms, url) {
method_with_parms();
}
-
-_DummyRequestManager.prototype.receivedResult = function() {
- }
var _dummyRequestManager = new _DummyRequestManager();
@@ -198,7 +195,6 @@
throw(e);
}
}
- self.requestManager.receivedResult();
if (exc == null) {
self.callback(res, supplementData, requestId);
} else {
Modified: z3/jsonserver/branch/merge/browser/requestmanager.js
==============================================================================
--- z3/jsonserver/branch/merge/browser/requestmanager.js (original)
+++ z3/jsonserver/branch/merge/browser/requestmanager.js Wed Aug 2 11:29:05 2006
@@ -19,7 +19,6 @@
- notifyServer(func, url) , where func is a partial containing
all parameters,
-- receivedResult() when result is received or an error is signalled.
*/
@@ -66,6 +65,15 @@
jsonrpc.RequestManager.prototype.pushSentRequest = function(func, url) {
// we do not store the elems, since they are not needed now
this.sentNr = this.sentNr + 1;
+ // Wrap up the callback func
+ var self = this;
+ var wrapped = function() {
+ // calls result processing
+ self.receivedResult(slot);
+ // calls the callback
+ func();
+ };
+ return wrapped;
}
jsonrpc.RequestManager.prototype.popSentRequest = function() {
@@ -76,22 +84,6 @@
return (this.sentNr >= this.maxNr)
}
-/* request manager notification API */
-
-jsonrpc.RequestManager.prototype.notifyServer = function(func, url) {
- // func must be a partial (e.g. use Mochikit or wrap up)
- // here url is only for the logging
- if (! this.isSentRequestQueueFull()) {
- // can be sent if we are not over the limit.
- this.pushSentRequest(func, url);
- this.log('Notify server at ' + url);
- func();
- } else {
- this.pushWaitingRequest(func, url);
- this.log('Queue server notification at ' + url);
- }
-}
-
jsonrpc.RequestManager.prototype.receivedResult = function() {
// must be called when one result arrived
// Mark that we have one less request out.
@@ -102,14 +94,29 @@
var waiting = this.popWaitingRequest();
var func = waiting[0];
var url = waiting[1];
- this.pushSentRequest(func, url);
+ var wrapped = this.pushSentRequest(func, url);
this.log("Send queued notification to server at " + url);
- func();
+ wrapped();
} else {
this.log("Request queue empty.");
}
}
+/* request manager notification API */
+
+jsonrpc.RequestManager.prototype.notifyServer = function(func, url) {
+ // func must be a partial (e.g. use Mochikit or wrap up)
+ // here url is only for the logging
+ if (! this.isSentRequestQueueFull()) {
+ // can be sent if we are not over the limit.
+ var wrapped = this.pushSentRequest(func, url);
+ this.log('Notify server at ' + url);
+ wrapped();
+ } else {
+ this.pushWaitingRequest(func, url);
+ this.log('Queue server notification at ' + url);
+ }
+}
/* simple FIFO queue */
jsonrpc.FifoQueue = function () {
More information about the z3-checkins
mailing list