Add callbackdata parameter in JavaScript OpenSRF message handling. user/dyrcona/lp939535
authorJason Stephenson <jstephenson@mvlc.org>
Thu, 23 Feb 2012 14:29:04 +0000 (09:29 -0500)
committerJason Stephenson <jstephenson@mvlc.org>
Thu, 23 Feb 2012 14:29:04 +0000 (09:29 -0500)
This allows callbacks to communicate state with each other in the
staff client.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
src/javascript/opensrf.js
src/javascript/opensrf_xhr.js

index dfff52a..9543797 100644 (file)
@@ -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);
         }
     }
 };
index ccc3ffd..e8cc199 100644 (file)
@@ -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
         }
     );
 };