Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /naja/src/js/rpc/NajaClient.class.js

naja
Discussion topic

Back to topic list

CVS update: /naja/src/js/rpc/NajaClient.class.js

Reply

Author pablo_cabrera
Full name Pablo J. Cabrera Munoz
Date 2006-05-28 09:06:04 PDT
Message User: pablo_cabrera
Date: 2006-05-28 09:06:04-0700
Log:
 no message

File Changes:

Directory: /naja/src/js/rpc/
============================

File [changed]: NajaClient.class.js
Url: http://naja.tigris.o​rg/source/browse/naj​a/src/js/rpc/NajaCli​ent.class.js?r1=1.2​&r2=1.3
Delta lines: +58 -38
---------------------
--- NajaClient.class.js 2006-05-27 13:13:52-0700 1.2
+++ NajaClient.class.js 2006-05-28 09:06:02-0700 1.3
@@ -18,6 +18,7 @@
     $object.endPoint = "";
     $object.clientId = null;
     $object.serializers = new Array;
+ $object.cached = true;
 
     /* Setters & Getters */
     $object.getCache = function() {
@@ -52,6 +53,14 @@
         return $this.serializers;
     }
 
+ $object.setCached = function(pValue) {
+ $this.cached = pValue;
+ }
+
+ $object.isCached = function() {
+ return $this.cached;
+ }
+
     /**
      * Get a serializer
      *
@@ -232,6 +241,8 @@
         var messageResponse = pMessage.getResponse();
         var hashMessage = pMessage.getHashMessage();
 
+ if (pMessage.isCached()) {
+
         requester.abort();
         requester.open("POST", $this.endPoint, false);
         requester.setRequest​Header("Content-Type​", "text/xml");
@@ -257,8 +268,9 @@
         }
 
         var returnType = returnMessage.getType();
+ }
 
- if (returnType == "HASH_RESPONSE") {
+ if (returnType == "HASH_RESPONSE" || !pMessage.isCached()) {
             var message = pMessage.getMessage();
 
             requester.abort();
@@ -342,6 +354,7 @@
                 requester = null;
                 throw new $NajaException("Invalid XML.");
             }
+ }
 
             if ($empty($this.clientId) && !$empty(returnMessa​ge.getClientId())) {
                 $this.clientId = returnMessage.getClientId();
@@ -357,7 +370,6 @@
             $this._cache.storeM​essage($clone(retur​nMessage));
             return $clone(returnMessage);
         }
- }
 
     /**
      * Calls an asynchronous request
@@ -377,7 +389,11 @@
         pMessage.setClientId​($this.clientId);
         pMessage.createMessage();
 
- var hashMessage = pMessage.getHashMessage();
+ if (pMessage.isCached()) {
+ var message = pMessage.getHashMessage();
+ } else {
+ var message = pMessage.getMessage();
+ }
 
         requester.setOnReady​StateChange(function​() {});
         requester.abort();
@@ -401,7 +417,7 @@
                 }\
             }\
         "));
- requester.send(hashMessage);
+ requester.send(message);
     }
 
     /**
@@ -518,6 +534,8 @@
                 }\
             "));
             pRequester.send(message);
+ } else {
+ $this._processRespo​nseMessage(returnMes​sage, pRequester, pCallBackId);
         }
     }
 
@@ -572,6 +590,7 @@
             message.setHashCode(​messageElement.getAt​tribute("HASHCODE"))​;
             message.setTransport​(messageElement.getA​ttribute("TRANSPORT"​));
             message.setType(mess​ageElement.getAttrib​ute("TYPE"));
+ message.setCached(me​ssageElement.getAttr​ibute("CACHED") == "TRUE");
 
             var replyValue = null;
             var errorValue = null;
@@ -694,6 +713,7 @@
 
         var najaMessage = new NajaMessage();
         najaMessage.setMethod("whois");
+ najaMessage.setCached(false);
         najaMessage.setRespo​nse($this.getEncodi​ngs());
         najaMessage.setEncod​ing("PLAIN");
         var returnMessage = $this.callSync(najaMessage);
@@ -754,8 +774,8 @@
 
 
 
- var syncFunction = eval("new Function("+evalParam​sDeclared+"\"var client = $nj.getObject("+$t​his.getObjectId()+")​;var serializer = client.getUsableSerializer(); var transport = serializer.getTransport(); var message = new NajaMessage(); message.setTransport​(transport); message.setResponse(​client.getUsableClie​ntEncoding()); message.setEncoding(​serializer.getEncodi​ng()); message.setMethod('"​+pMethod.getName()+"​'); message.setModule('"​+pModule.getName()+"​'); message.setParams(new Array("+evalParams+")); return client.decodeMessage​(client.callSync(mes​sage));\");");
- var asyncFunction = eval("new Function("+evalParam​sDeclared+"\"pCallB​ack\", \"var client = $nj.getObject("+$t​his.getObjectId()+")​; var callBackId = client.storeCallBack​(pCallBack); var serializer = client.getUsableSerializer(); var transport = serializer.getTransport(); var message = new NajaMessage(); message.setTransport​(transport); message.setEncoding(​serializer.getEncodi​ng()); message.setResponse(​client.getUsableClie​ntEncoding()); message.setMethod('"​+pMethod.getName()+"​'); message.setModule('"​+pModule.getName()+"​'); message.setParams(new Array("+evalParams+")); client.callAsync(message, new Function('pReturn', 'var client = $nj.getObject("+$t​his.getObjectId()+")​; client.processCallBa​ck('+callBackId+', pReturn); client.deleteCallBac​k('+callBackId+');')​);\");");
+ var syncFunction = eval("new Function("+evalParam​sDeclared+"\"var client = $nj.getObject("+$t​his.getObjectId()+")​;var serializer = client.getUsableSerializer(); var transport = serializer.getTransport(); var message = new NajaMessage(); message.setCached(cl​ient.isCached()); message.setTransport​(transport); message.setResponse(​client.getUsableClie​ntEncoding()); message.setEncoding(​serializer.getEncodi​ng()); message.setMethod('"​+pMethod.getName()+"​'); message.setModule('"​+pModule.getName()+"​'); message.setParams(new Array("+evalParams+")); return client.decodeMessage​(client.callSync(mes​sage));\");");
+ var asyncFunction = eval("new Function("+evalParam​sDeclared+"\"pCallB​ack\", \"var client = $nj.getObject("+$t​his.getObjectId()+")​; var callBackId = client.storeCallBack​(pCallBack); var serializer = client.getUsableSerializer(); var transport = serializer.getTransport(); var message = new NajaMessage(); message.setCached(cl​ient.isCached()); message.setTransport​(transport); message.setEncoding(​serializer.getEncodi​ng()); message.setResponse(​client.getUsableClie​ntEncoding()); message.setMethod('"​+pMethod.getName()+"​'); message.setModule('"​+pModule.getName()+"​'); message.setParams(new Array("+evalParams+")); client.callAsync(message, new Function('pReturn', 'var client = $nj.getObject("+$t​his.getObjectId()+")​; client.processCallBa​ck('+callBackId+', pReturn); client.deleteCallBac​k('+callBackId+');')​);\");");
 
         pModule[pMethod.getN​ame()+"Sync"] = syncFunction;
         pModule[pMethod.getName()] = asyncFunction;

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /naja/src/js/rpc/NajaClient.class.js pablo_cabrera Pablo J. Cabrera Munoz 2006-05-28 09:06:04 PDT
Messages per page: