From: Jason Stephenson Date: Thu, 23 Feb 2012 14:29:04 +0000 (-0500) Subject: Add callbackdata parameter in JavaScript OpenSRF message handling. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fdyrcona%2Flp939535;p=working%2FOpenSRF.git Add callbackdata parameter in JavaScript OpenSRF message handling. This allows callbacks to communicate state with each other in the staff client. Signed-off-by: Jason Stephenson --- diff --git a/src/javascript/opensrf.js b/src/javascript/opensrf.js index dfff52a..9543797 100644 --- a/src/javascript/opensrf.js +++ b/src/javascript/opensrf.js @@ -327,6 +327,7 @@ OpenSRF.Request = function(session, reqid, args) { this.onerror = args.onerror; this.onmethoderror = args.onmethoderror; this.ontransporterror = args.ontransporterror; + this.callbackdata = args.callbackdata; this.method = args.method; this.params = args.params; @@ -371,7 +372,8 @@ OpenSRF.Request.prototype.send = function() { 'oncomplete' : this.oncomplete, 'onerror' : this.onerror, 'onmethoderror' : this.onmethoderror, - 'ontransporterror' : this.ontransporterror + 'ontransporterror' : this.ontransporterror, + 'callbackdata' : this.callbackdata }); }; @@ -421,7 +423,7 @@ OpenSRF.Stack.handle_message = function(ses, osrf_msg, callbacks) { req.complete = true; if(callbacks.oncomplete && !req.oncomplete_called) { req.oncomplete_called = true; - return callbacks.oncomplete(req); + return callbacks.oncomplete(req, callbacks.callbackdata); } } } @@ -448,7 +450,7 @@ OpenSRF.Stack.handle_message = function(ses, osrf_msg, callbacks) { if(req) { req.response_queue.push(osrf_msg.payload()); if(callbacks.onresponse) - return callbacks.onresponse(req); + return callbacks.onresponse(req, callbacks.callbackdata); } } }; diff --git a/src/javascript/opensrf_xhr.js b/src/javascript/opensrf_xhr.js index ccc3ffd..e8cc199 100644 --- a/src/javascript/opensrf_xhr.js +++ b/src/javascript/opensrf_xhr.js @@ -107,7 +107,8 @@ OpenSRF.XHRequest.prototype.core_handler = function() { onresponse : this.args.onresponse, oncomplete : this.args.oncomplete, onerror : this.args.onerror, - onmethoderror : this.method_error_handler() + onmethoderror : this.method_error_handler(), + callbackdata : this.args.callbackdata } ); };