Login | Register
My pages Projects Community openCollabNet

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

naja
Discussion topic

Back to topic list

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

Reply

Author pablo_cabrera
Full name Pablo J. Cabrera Munoz
Date 2006-05-27 06:37:13 PDT
Message User: pablo_cabrera
Date: 2006-05-27 06:37:13-0700
Log:
 no message

File Changes:

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

File [changed]: NajaMessage.class.js
Url: http://naja.tigris.o​rg/source/browse/naj​a/src/js/rpc/NajaCli​ent/NajaMessage.clas​s.js?r1=1.1&r2=1​.2
Delta lines: +51 -7
--------------------
--- NajaMessage.class.js 2006-05-23 19:30:45-0700 1.1
+++ NajaMessage.class.js 2006-05-27 06:37:07-0700 1.2
@@ -15,6 +15,7 @@
     $object.type = null;
     $object.message = null;
     $object.hashMessage = null;
+ $object.transport = null;
 
     /**
      * Setters & getters
@@ -113,24 +114,67 @@
         return $this.hashMessage;
     }
 
+ $object.setTransport = function(pValue) {
+ $this.transport = pValue;
+ }
+
+ $object.getTransport = function() {
+ return $this.transport;
+ }
+
     $object.createMessage = function() {
         var packet = "";
 
+ var transport = "PLAIN";
+ if (!$empty($this.transport)) {
+ transport = $this.transport;
+ }
+
+
         if ($this.module != null) {
             packet += "<MODULE>"+(""​+$this.module).esca​peEntity()+"</MOD​ULE>";
         }
 
+ if ($this.method != null) {
+ packet += "<METHOD>"+(""​+$this.method).esca​peEntity()+"</MET​HOD>";
+ }
+
+ var reply = "";
         if ($this.reply != null) {
- packet += "<REPLY>"+(""+​$this.reply).escape​Entity()+"</REPLY​>";
+ reply = $this.reply;
         }
 
- if ($this.method != null) {
- packet += "<METHOD>"+(""​+$this.method).esca​peEntity()+"</MET​HOD>";
+ var params = null;
+ if (!$empty($this.params)) {
+ params = $clone($this.params);
+ }
+
+ var codec = Codec.getInstance();
+ if (transport == "BASE64") {
+ reply = codec.encodeBase64(reply);
+
+ if (!$empty(params)) {
+ for (var i = 0; i < params.length; i++) {
+ params[i] = codec.encodeBase64(params[i]);
+ }
+ }
+ } else if (transport == "URLENCODED") {
+ reply = codec.urlEncode(reply);
+
+ if (!$empty(params)) {
+ for (var i = 0; i < params.length; i++) {
+ params[i] = codec.urlEncode(params[i]);
+ }
+ }
+ }
+
+ if (!$empty(reply)) {
+ packet += "<REPLY>"+repl​y.escapeEntity()+"​</REPLY>";
         }
 
- if ($this.params != null) {
- for (var i =0; i < this.params.length; i++) {
- packet += "<PARAM>"+(""+​$this.params[i]).es​capeEntity()+"</P​ARAM>";
+ if (!$empty(params)) {
+ for (var i =0; i < params.length; i++) {
+ packet += "<PARAM>"+(""+​params[i]).escapeEnt​ity()+"</PARAM​>";
             }
         }
 
@@ -151,7 +195,7 @@
             clientId = $this.clientId;
         }
 
- var message = '<?xml version="1.0" encoding="UTF-8"?​><MESSAGE ID="'+id.escapeEntity()+'" CLIENTID="'+clientId​.escapeEntity()+'" ';
+ var message = '<?xml version="1.0" encoding="UTF-8"?​><MESSAGE ID="'+id.escapeEntity()+'" CLIENTID="'+clientId​.escapeEntity()+'" TRANSPORT="'+(""+tra​nsport).escapeEntity​()+'" ';
         $this.hashMessage = '<?xml version="1.0" encoding="UTF-8"?​><MESSAGE ID="'+id.escapeEntity()+'" CLIENTID="'+clientId​.escapeEntity()+'" TYPE="HASHCODE" HASHCODE="'+$this.h​ashCode.escapeEntity​()+'" />';
 
         var encoding = "PLAIN"

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

Messages

Show all messages in topic

CVS update: /naja/src/js/rpc/NajaClient/NajaMessage.class.js pablo_cabrera Pablo J. Cabrera Munoz 2006-05-27 06:37:13 PDT
Messages per page: