blob: ada28bae8cf97dae0380265d70d082845d5034ac [file] [log] [blame]
Henrique Mendonça095ddb72013-09-20 19:38:03 +02001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20/*jshint evil:true*/
21
22/**
23 * The Thrift namespace houses the Apache Thrift JavaScript library
24 * elements providing JavaScript bindings for the Apache Thrift RPC
henrique2a7dccc2014-03-07 22:16:51 +010025 * system. End users will typically only directly make use of the
26 * Transport (TXHRTransport/TWebSocketTransport) and Protocol
27 * (TJSONPRotocol/TBinaryProtocol) constructors.
28 *
29 * Object methods beginning with a __ (e.g. __onOpen()) are internal
30 * and should not be called outside of the object's own methods.
31 *
32 * This library creates one global object: Thrift
33 * Code in this library must never create additional global identifiers,
34 * all features must be scoped within the Thrift namespace.
Henrique Mendonça095ddb72013-09-20 19:38:03 +020035 * @namespace
36 * @example
37 * var transport = new Thrift.Transport("http://localhost:8585");
38 * var protocol = new Thrift.Protocol(transport);
39 * var client = new MyThriftSvcClient(protocol);
40 * var result = client.MyMethod();
41 */
42var Thrift = {
43 /**
44 * Thrift JavaScript library version.
45 * @readonly
46 * @const {string} Version
47 * @memberof Thrift
48 */
49 Version: '1.0.0-dev',
50
51 /**
52 * Thrift IDL type string to Id mapping.
53 * @readonly
54 * @property {number} STOP - End of a set of fields.
55 * @property {number} VOID - No value (only legal for return types).
56 * @property {number} BOOL - True/False integer.
57 * @property {number} BYTE - Signed 8 bit integer.
58 * @property {number} I08 - Signed 8 bit integer.
59 * @property {number} DOUBLE - 64 bit IEEE 854 floating point.
60 * @property {number} I16 - Signed 16 bit integer.
61 * @property {number} I32 - Signed 32 bit integer.
62 * @property {number} I64 - Signed 64 bit integer.
63 * @property {number} STRING - Array of bytes representing a string of characters.
64 * @property {number} UTF7 - Array of bytes representing a string of UTF7 encoded characters.
65 * @property {number} STRUCT - A multifield type.
66 * @property {number} MAP - A collection type (map/associative-array/dictionary).
67 * @property {number} SET - A collection type (unordered and without repeated values).
68 * @property {number} LIST - A collection type (unordered).
69 * @property {number} UTF8 - Array of bytes representing a string of UTF8 encoded characters.
70 * @property {number} UTF16 - Array of bytes representing a string of UTF16 encoded characters.
71 */
72 Type: {
73 'STOP' : 0,
74 'VOID' : 1,
75 'BOOL' : 2,
76 'BYTE' : 3,
77 'I08' : 3,
78 'DOUBLE' : 4,
79 'I16' : 6,
80 'I32' : 8,
81 'I64' : 10,
82 'STRING' : 11,
83 'UTF7' : 11,
84 'STRUCT' : 12,
85 'MAP' : 13,
86 'SET' : 14,
87 'LIST' : 15,
88 'UTF8' : 16,
89 'UTF16' : 17
90 },
91
92 /**
93 * Thrift RPC message type string to Id mapping.
94 * @readonly
95 * @property {number} CALL - RPC call sent from client to server.
96 * @property {number} REPLY - RPC call normal response from server to client.
97 * @property {number} EXCEPTION - RPC call exception response from server to client.
98 * @property {number} ONEWAY - Oneway RPC call from client to server with no response.
99 */
100 MessageType: {
101 'CALL' : 1,
102 'REPLY' : 2,
103 'EXCEPTION' : 3,
104 'ONEWAY' : 4
105 },
106
107 /**
108 * Utility function returning the count of an object's own properties.
109 * @param {object} obj - Object to test.
110 * @returns {number} number of object's own properties
111 */
112 objectLength: function(obj) {
113 var length = 0;
114 for (var k in obj) {
115 if (obj.hasOwnProperty(k)) {
116 length++;
117 }
118 }
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200119 return length;
120 },
121
122 /**
123 * Utility function to establish prototype inheritance.
124 * @see {@link http://javascript.crockford.com/prototypal.html|Prototypal Inheritance}
125 * @param {function} constructor - Contstructor function to set as derived.
126 * @param {function} superConstructor - Contstructor function to set as base.
127 * @param {string} [name] - Type name to set as name property in derived prototype.
128 */
129 inherits: function(constructor, superConstructor, name) {
130 function F() {}
131 F.prototype = superConstructor.prototype;
132 constructor.prototype = new F();
133 constructor.prototype.name = name || "";
134 }
135};
136
137/**
138 * Initializes a Thrift TException instance.
139 * @constructor
140 * @augments Error
141 * @param {string} message - The TException message (distinct from the Error message).
142 * @classdesc TException is the base class for all Thrift exceptions types.
143 */
144Thrift.TException = function(message) {
145 this.message = message;
146};
147Thrift.inherits(Thrift.TException, Error, 'TException');
148
149/**
150 * Returns the message set on the exception.
151 * @readonly
152 * @returns {string} exception message
153 */
154Thrift.TException.prototype.getMessage = function() {
155 return this.message;
156};
157
158/**
159 * Thrift Application Exception type string to Id mapping.
160 * @readonly
161 * @property {number} UNKNOWN - Unknown/undefined.
162 * @property {number} UNKNOWN_METHOD - Client attempted to call a method unknown to the server.
163 * @property {number} INVALID_MESSAGE_TYPE - Client passed an unknown/unsupported MessageType.
164 * @property {number} WRONG_METHOD_NAME - Unused.
165 * @property {number} BAD_SEQUENCE_ID - Unused in Thrift RPC, used to flag proprietary sequence number errors.
166 * @property {number} MISSING_RESULT - Raised by a server processor if a handler fails to supply the required return result.
167 * @property {number} INTERNAL_ERROR - Something bad happened.
168 * @property {number} PROTOCOL_ERROR - The protocol layer failed to serialize or deserialize data.
169 * @property {number} INVALID_TRANSFORM - Unused.
170 * @property {number} INVALID_PROTOCOL - The protocol (or version) is not supported.
171 * @property {number} UNSUPPORTED_CLIENT_TYPE - Unused.
172 */
173Thrift.TApplicationExceptionType = {
174 'UNKNOWN' : 0,
175 'UNKNOWN_METHOD' : 1,
176 'INVALID_MESSAGE_TYPE' : 2,
177 'WRONG_METHOD_NAME' : 3,
178 'BAD_SEQUENCE_ID' : 4,
179 'MISSING_RESULT' : 5,
180 'INTERNAL_ERROR' : 6,
181 'PROTOCOL_ERROR' : 7,
182 'INVALID_TRANSFORM' : 8,
183 'INVALID_PROTOCOL' : 9,
184 'UNSUPPORTED_CLIENT_TYPE' : 10
185};
186
187/**
188 * Initializes a Thrift TApplicationException instance.
189 * @constructor
190 * @augments Thrift.TException
191 * @param {string} message - The TApplicationException message (distinct from the Error message).
192 * @param {Thrift.TApplicationExceptionType} [code] - The TApplicationExceptionType code.
193 * @classdesc TApplicationException is the exception class used to propagate exceptions from an RPC server back to a calling client.
194*/
195Thrift.TApplicationException = function(message, code) {
196 this.message = message;
197 this.code = typeof code === "number" ? code : 0;
198};
199Thrift.inherits(Thrift.TApplicationException, Thrift.TException, 'TApplicationException');
200
201/**
202 * Read a TApplicationException from the supplied protocol.
203 * @param {object} input - The input protocol to read from.
204 */
205Thrift.TApplicationException.prototype.read = function(input) {
206 while (1) {
207 var ret = input.readFieldBegin();
208
209 if (ret.ftype == Thrift.Type.STOP) {
210 break;
211 }
212
213 var fid = ret.fid;
214
215 switch (fid) {
216 case 1:
217 if (ret.ftype == Thrift.Type.STRING) {
218 ret = input.readString();
219 this.message = ret.value;
220 } else {
221 ret = input.skip(ret.ftype);
222 }
223 break;
224 case 2:
225 if (ret.ftype == Thrift.Type.I32) {
226 ret = input.readI32();
227 this.code = ret.value;
228 } else {
229 ret = input.skip(ret.ftype);
230 }
231 break;
232 default:
233 ret = input.skip(ret.ftype);
234 break;
235 }
236
237 input.readFieldEnd();
238 }
239
240 input.readStructEnd();
241};
242
243/**
244 * Wite a TApplicationException to the supplied protocol.
245 * @param {object} output - The output protocol to write to.
246 */
247Thrift.TApplicationException.prototype.write = function(output) {
248 output.writeStructBegin('TApplicationException');
249
250 if (this.message) {
251 output.writeFieldBegin('message', Thrift.Type.STRING, 1);
252 output.writeString(this.getMessage());
253 output.writeFieldEnd();
254 }
255
256 if (this.code) {
257 output.writeFieldBegin('type', Thrift.Type.I32, 2);
258 output.writeI32(this.code);
259 output.writeFieldEnd();
260 }
261
262 output.writeFieldStop();
263 output.writeStructEnd();
264};
265
266/**
267 * Returns the application exception code set on the exception.
268 * @readonly
269 * @returns {Thrift.TApplicationExceptionType} exception code
270 */
271Thrift.TApplicationException.prototype.getCode = function() {
272 return this.code;
273};
274
275/**
henrique2a7dccc2014-03-07 22:16:51 +0100276 * Constructor Function for the XHR transport.
277 * If you do not specify a url then you must handle XHR operations on
278 * your own. This type can also be constructed using the Transport alias
279 * for backward compatibility.
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200280 * @constructor
281 * @param {string} [url] - The URL to connect to.
henrique2a7dccc2014-03-07 22:16:51 +0100282 * @classdesc The Apache Thrift Transport layer performs byte level I/O
283 * between RPC clients and servers. The JavaScript TXHRTransport object
284 * uses Http[s]/XHR. Target servers must implement the http[s] transport
285 * (see: node.js example server_http.js).
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200286 * @example
henrique2a7dccc2014-03-07 22:16:51 +0100287 * var transport = new Thrift.TXHRTransport("http://localhost:8585");
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200288 */
Roger Meier52744ee2014-03-12 09:38:42 +0100289Thrift.Transport = Thrift.TXHRTransport = function(url, options) {
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200290 this.url = url;
291 this.wpos = 0;
292 this.rpos = 0;
Roger Meier52744ee2014-03-12 09:38:42 +0100293 this.useCORS = (options && options.useCORS);
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200294 this.send_buf = '';
295 this.recv_buf = '';
296};
297
henrique2a7dccc2014-03-07 22:16:51 +0100298Thrift.TXHRTransport.prototype = {
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200299 /**
300 * Gets the browser specific XmlHttpRequest Object.
301 * @returns {object} the browser XHR interface object
302 */
303 getXmlHttpRequestObject: function() {
304 try { return new XMLHttpRequest(); } catch (e1) { }
305 try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch (e2) { }
306 try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch (e3) { }
307
308 throw "Your browser doesn't support XHR.";
309 },
310
311 /**
henrique2a7dccc2014-03-07 22:16:51 +0100312 * Sends the current XRH request if the transport was created with a URL
313 * and the async parameter is false. If the transport was not created with
314 * a URL, or the async parameter is True and no callback is provided, or
315 * the URL is an empty string, the current send buffer is returned.
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200316 * @param {object} async - If true the current send buffer is returned.
henrique2a7dccc2014-03-07 22:16:51 +0100317 * @param {object} callback - Optional async completion callback
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200318 * @returns {undefined|string} Nothing or the current send buffer.
319 * @throws {string} If XHR fails.
320 */
henriquea2de4102014-02-07 14:12:56 +0100321 flush: function(async, callback) {
henrique2a7dccc2014-03-07 22:16:51 +0100322 var self = this;
henriquea2de4102014-02-07 14:12:56 +0100323 if ((async && !callback) || this.url === undefined || this.url === '') {
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200324 return this.send_buf;
325 }
326
327 var xreq = this.getXmlHttpRequestObject();
328
329 if (xreq.overrideMimeType) {
henrique1e723d92015-05-01 14:09:00 +1000330 xreq.overrideMimeType('application/vnd.apache.thrift.json; charset=utf-8');
331 }
332 if (xreq.setRequestHeader) {
333 xreq.setRequestHeader('Accept', 'application/vnd.apache.thrift.json; charset=utf-8');
334 xreq.setRequestHeader('Content-Type', 'application/vnd.apache.thrift.json; charset=utf-8');
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200335 }
336
henriquea2de4102014-02-07 14:12:56 +0100337 if (callback) {
henrique2a7dccc2014-03-07 22:16:51 +0100338 //Ignore XHR callbacks until the data arrives, then call the
339 // client's callback
340 xreq.onreadystatechange =
341 (function() {
342 var clientCallback = callback;
343 return function() {
344 if (this.readyState == 4 && this.status == 200) {
345 self.setRecvBuffer(this.responseText);
346 clientCallback();
347 }
348 };
349 }());
henriquea2de4102014-02-07 14:12:56 +0100350 }
351
352 xreq.open('POST', this.url, !!async);
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200353 xreq.send(this.send_buf);
henriquea2de4102014-02-07 14:12:56 +0100354 if (async && callback) {
355 return;
356 }
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200357
358 if (xreq.readyState != 4) {
359 throw 'encountered an unknown ajax ready state: ' + xreq.readyState;
360 }
361
362 if (xreq.status != 200) {
363 throw 'encountered a unknown request status: ' + xreq.status;
364 }
365
366 this.recv_buf = xreq.responseText;
367 this.recv_buf_sz = this.recv_buf.length;
368 this.wpos = this.recv_buf.length;
369 this.rpos = 0;
370 },
371
372 /**
373 * Creates a jQuery XHR object to be used for a Thrift server call.
374 * @param {object} client - The Thrift Service client object generated by the IDL compiler.
375 * @param {object} postData - The message to send to the server.
henrique2a7dccc2014-03-07 22:16:51 +0100376 * @param {function} args - The original call arguments with the success call back at the end.
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200377 * @param {function} recv_method - The Thrift Service Client receive method for the call.
378 * @returns {object} A new jQuery XHR object.
379 * @throws {string} If the jQuery version is prior to 1.5 or if jQuery is not found.
380 */
381 jqRequest: function(client, postData, args, recv_method) {
382 if (typeof jQuery === 'undefined' ||
383 typeof jQuery.Deferred === 'undefined') {
384 throw 'Thrift.js requires jQuery 1.5+ to use asynchronous requests';
385 }
386
387 var thriftTransport = this;
388
389 var jqXHR = jQuery.ajax({
390 url: this.url,
391 data: postData,
392 type: 'POST',
393 cache: false,
henrique1e723d92015-05-01 14:09:00 +1000394 contentType: 'application/vnd.apache.thrift.json; charset=utf-8',
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200395 dataType: 'text thrift',
396 converters: {
397 'text thrift' : function(responseData) {
398 thriftTransport.setRecvBuffer(responseData);
399 var value = recv_method.call(client);
400 return value;
401 }
402 },
403 context: client,
404 success: jQuery.makeArray(args).pop()
405 });
406
407 return jqXHR;
408 },
409
410 /**
henrique2a7dccc2014-03-07 22:16:51 +0100411 * Sets the buffer to provide the protocol when deserializing.
412 * @param {string} buf - The buffer to supply the protocol.
413 */
414 setRecvBuffer: function(buf) {
415 this.recv_buf = buf;
416 this.recv_buf_sz = this.recv_buf.length;
417 this.wpos = this.recv_buf.length;
418 this.rpos = 0;
419 },
420
421 /**
422 * Returns true if the transport is open, XHR always returns true.
423 * @readonly
424 * @returns {boolean} Always True.
425 */
426 isOpen: function() {
427 return true;
428 },
429
430 /**
431 * Opens the transport connection, with XHR this is a nop.
432 */
433 open: function() {},
434
435 /**
436 * Closes the transport connection, with XHR this is a nop.
437 */
438 close: function() {},
439
440 /**
441 * Returns the specified number of characters from the response
442 * buffer.
443 * @param {number} len - The number of characters to return.
444 * @returns {string} Characters sent by the server.
445 */
446 read: function(len) {
447 var avail = this.wpos - this.rpos;
448
449 if (avail === 0) {
450 return '';
451 }
452
453 var give = len;
454
455 if (avail < len) {
456 give = avail;
457 }
458
459 var ret = this.read_buf.substr(this.rpos, give);
460 this.rpos += give;
461
462 //clear buf when complete?
463 return ret;
464 },
465
466 /**
467 * Returns the entire response buffer.
468 * @returns {string} Characters sent by the server.
469 */
470 readAll: function() {
471 return this.recv_buf;
472 },
473
474 /**
475 * Sets the send buffer to buf.
476 * @param {string} buf - The buffer to send.
477 */
478 write: function(buf) {
479 this.send_buf = buf;
480 },
481
482 /**
483 * Returns the send buffer.
484 * @readonly
485 * @returns {string} The send buffer.
486 */
487 getSendBuffer: function() {
488 return this.send_buf;
489 }
490
491};
492
493
494/**
495 * Constructor Function for the WebSocket transport.
496 * @constructor
497 * @param {string} [url] - The URL to connect to.
498 * @classdesc The Apache Thrift Transport layer performs byte level I/O
499 * between RPC clients and servers. The JavaScript TWebSocketTransport object
500 * uses the WebSocket protocol. Target servers must implement WebSocket.
501 * (see: node.js example server_http.js).
502 * @example
503 * var transport = new Thrift.TWebSocketTransport("http://localhost:8585");
504 */
505Thrift.TWebSocketTransport = function(url) {
506 this.__reset(url);
507};
508
509Thrift.TWebSocketTransport.prototype = {
510 __reset: function(url) {
511 this.url = url; //Where to connect
512 this.socket = null; //The web socket
513 this.callbacks = []; //Pending callbacks
514 this.send_pending = []; //Buffers/Callback pairs waiting to be sent
515 this.send_buf = ''; //Outbound data, immutable until sent
516 this.recv_buf = ''; //Inbound data
517 this.rb_wpos = 0; //Network write position in receive buffer
518 this.rb_rpos = 0; //Client read position in receive buffer
519 },
520
521 /**
522 * Sends the current WS request and registers callback. The async
523 * parameter is ignored (WS flush is always async) and the callback
524 * function parameter is required.
525 * @param {object} async - Ignored.
526 * @param {object} callback - The client completion callback.
527 * @returns {undefined|string} Nothing (undefined)
528 */
529 flush: function(async, callback) {
530 var self = this;
531 if (this.isOpen()) {
532 //Send data and register a callback to invoke the client callback
533 this.socket.send(this.send_buf);
534 this.callbacks.push((function() {
535 var clientCallback = callback;
536 return function(msg) {
537 self.setRecvBuffer(msg);
538 clientCallback();
539 };
540 }()));
541 } else {
542 //Queue the send to go out __onOpen
543 this.send_pending.push({
544 buf: this.send_buf,
545 cb: callback
546 });
547 }
548 },
549
550 __onOpen: function() {
551 var self = this;
552 if (this.send_pending.length > 0) {
553 //If the user made calls before the connection was fully
554 //open, send them now
555 this.send_pending.forEach(function(elem) {
556 this.socket.send(elem.buf);
557 this.callbacks.push((function() {
558 var clientCallback = elem.cb;
559 return function(msg) {
560 self.setRecvBuffer(msg);
561 clientCallback();
562 };
563 }()));
564 });
565 this.send_pending = [];
566 }
567 },
568
569 __onClose: function(evt) {
570 this.__reset(this.url);
571 },
572
573 __onMessage: function(evt) {
574 if (this.callbacks.length) {
575 this.callbacks.shift()(evt.data);
576 }
577 },
578
579 __onError: function(evt) {
580 console.log("Thrift WebSocket Error: " + evt.toString());
581 this.socket.close();
582 },
583
584 /**
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200585 * Sets the buffer to use when receiving server responses.
586 * @param {string} buf - The buffer to receive server responses.
587 */
588 setRecvBuffer: function(buf) {
589 this.recv_buf = buf;
590 this.recv_buf_sz = this.recv_buf.length;
591 this.wpos = this.recv_buf.length;
592 this.rpos = 0;
593 },
594
595 /**
henrique2a7dccc2014-03-07 22:16:51 +0100596 * Returns true if the transport is open
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200597 * @readonly
henrique2a7dccc2014-03-07 22:16:51 +0100598 * @returns {boolean}
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200599 */
600 isOpen: function() {
henrique2a7dccc2014-03-07 22:16:51 +0100601 return this.socket && this.socket.readyState == this.socket.OPEN;
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200602 },
603
604 /**
henrique2a7dccc2014-03-07 22:16:51 +0100605 * Opens the transport connection
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200606 */
henrique2a7dccc2014-03-07 22:16:51 +0100607 open: function() {
608 //If OPEN/CONNECTING/CLOSING ignore additional opens
609 if (this.socket && this.socket.readyState != this.socket.CLOSED) {
610 return;
611 }
612 //If there is no socket or the socket is closed:
613 this.socket = new WebSocket(this.url);
614 this.socket.onopen = this.__onOpen.bind(this);
615 this.socket.onmessage = this.__onMessage.bind(this);
616 this.socket.onerror = this.__onError.bind(this);
617 this.socket.onclose = this.__onClose.bind(this);
618 },
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200619
620 /**
henrique2a7dccc2014-03-07 22:16:51 +0100621 * Closes the transport connection
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200622 */
henrique2a7dccc2014-03-07 22:16:51 +0100623 close: function() {
624 this.socket.close();
625 },
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200626
627 /**
628 * Returns the specified number of characters from the response
629 * buffer.
630 * @param {number} len - The number of characters to return.
631 * @returns {string} Characters sent by the server.
632 */
633 read: function(len) {
634 var avail = this.wpos - this.rpos;
635
636 if (avail === 0) {
637 return '';
638 }
639
640 var give = len;
641
642 if (avail < len) {
643 give = avail;
644 }
645
646 var ret = this.read_buf.substr(this.rpos, give);
647 this.rpos += give;
648
649 //clear buf when complete?
650 return ret;
651 },
652
653 /**
654 * Returns the entire response buffer.
655 * @returns {string} Characters sent by the server.
656 */
657 readAll: function() {
658 return this.recv_buf;
659 },
660
661 /**
662 * Sets the send buffer to buf.
663 * @param {string} buf - The buffer to send.
664 */
665 write: function(buf) {
666 this.send_buf = buf;
667 },
668
669 /**
670 * Returns the send buffer.
671 * @readonly
672 * @returns {string} The send buffer.
673 */
674 getSendBuffer: function() {
675 return this.send_buf;
676 }
677
678};
679
680/**
681 * Initializes a Thrift JSON protocol instance.
682 * @constructor
683 * @param {Thrift.Transport} transport - The transport to serialize to/from.
684 * @classdesc Apache Thrift Protocols perform serialization which enables cross
685 * language RPC. The Protocol type is the JavaScript browser implementation
686 * of the Apache Thrift TJSONProtocol.
687 * @example
688 * var protocol = new Thrift.Protocol(transport);
689 */
Roger Meier52744ee2014-03-12 09:38:42 +0100690Thrift.TJSONProtocol = Thrift.Protocol = function(transport) {
radekg1d305582015-01-01 20:35:01 +0100691 this.tstack = [];
692 this.tpos = [];
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200693 this.transport = transport;
694};
695
696/**
697 * Thrift IDL type Id to string mapping.
698 * @readonly
699 * @see {@link Thrift.Type}
700 */
701Thrift.Protocol.Type = {};
702Thrift.Protocol.Type[Thrift.Type.BOOL] = '"tf"';
703Thrift.Protocol.Type[Thrift.Type.BYTE] = '"i8"';
704Thrift.Protocol.Type[Thrift.Type.I16] = '"i16"';
705Thrift.Protocol.Type[Thrift.Type.I32] = '"i32"';
706Thrift.Protocol.Type[Thrift.Type.I64] = '"i64"';
707Thrift.Protocol.Type[Thrift.Type.DOUBLE] = '"dbl"';
708Thrift.Protocol.Type[Thrift.Type.STRUCT] = '"rec"';
709Thrift.Protocol.Type[Thrift.Type.STRING] = '"str"';
710Thrift.Protocol.Type[Thrift.Type.MAP] = '"map"';
711Thrift.Protocol.Type[Thrift.Type.LIST] = '"lst"';
712Thrift.Protocol.Type[Thrift.Type.SET] = '"set"';
713
714/**
715 * Thrift IDL type string to Id mapping.
716 * @readonly
717 * @see {@link Thrift.Type}
718 */
719Thrift.Protocol.RType = {};
720Thrift.Protocol.RType.tf = Thrift.Type.BOOL;
721Thrift.Protocol.RType.i8 = Thrift.Type.BYTE;
722Thrift.Protocol.RType.i16 = Thrift.Type.I16;
723Thrift.Protocol.RType.i32 = Thrift.Type.I32;
724Thrift.Protocol.RType.i64 = Thrift.Type.I64;
725Thrift.Protocol.RType.dbl = Thrift.Type.DOUBLE;
726Thrift.Protocol.RType.rec = Thrift.Type.STRUCT;
727Thrift.Protocol.RType.str = Thrift.Type.STRING;
728Thrift.Protocol.RType.map = Thrift.Type.MAP;
729Thrift.Protocol.RType.lst = Thrift.Type.LIST;
730Thrift.Protocol.RType.set = Thrift.Type.SET;
731
732/**
733 * The TJSONProtocol version number.
734 * @readonly
735 * @const {number} Version
736 * @memberof Thrift.Protocol
737 */
738 Thrift.Protocol.Version = 1;
739
740Thrift.Protocol.prototype = {
741 /**
742 * Returns the underlying transport.
743 * @readonly
744 * @returns {Thrift.Transport} The underlying transport.
745 */
746 getTransport: function() {
747 return this.transport;
748 },
749
750 /**
751 * Serializes the beginning of a Thrift RPC message.
752 * @param {string} name - The service method to call.
753 * @param {Thrift.MessageType} messageType - The type of method call.
754 * @param {number} seqid - The sequence number of this call (always 0 in Apache Thrift).
755 */
756 writeMessageBegin: function(name, messageType, seqid) {
757 this.tstack = [];
758 this.tpos = [];
759
760 this.tstack.push([Thrift.Protocol.Version, '"' +
761 name + '"', messageType, seqid]);
762 },
763
764 /**
765 * Serializes the end of a Thrift RPC message.
766 */
767 writeMessageEnd: function() {
768 var obj = this.tstack.pop();
769
770 this.wobj = this.tstack.pop();
771 this.wobj.push(obj);
772
773 this.wbuf = '[' + this.wobj.join(',') + ']';
774
775 this.transport.write(this.wbuf);
776 },
777
778
779 /**
780 * Serializes the beginning of a struct.
781 * @param {string} name - The name of the struct.
782 */
783 writeStructBegin: function(name) {
784 this.tpos.push(this.tstack.length);
785 this.tstack.push({});
786 },
787
788 /**
789 * Serializes the end of a struct.
790 */
791 writeStructEnd: function() {
792
793 var p = this.tpos.pop();
794 var struct = this.tstack[p];
795 var str = '{';
796 var first = true;
797 for (var key in struct) {
798 if (first) {
799 first = false;
800 } else {
801 str += ',';
802 }
803
804 str += key + ':' + struct[key];
805 }
806
807 str += '}';
808 this.tstack[p] = str;
809 },
810
811 /**
812 * Serializes the beginning of a struct field.
813 * @param {string} name - The name of the field.
814 * @param {Thrift.Protocol.Type} fieldType - The data type of the field.
815 * @param {number} fieldId - The field's unique identifier.
816 */
817 writeFieldBegin: function(name, fieldType, fieldId) {
818 this.tpos.push(this.tstack.length);
819 this.tstack.push({ 'fieldId': '"' +
820 fieldId + '"', 'fieldType': Thrift.Protocol.Type[fieldType]
821 });
822
823 },
824
825 /**
826 * Serializes the end of a field.
827 */
828 writeFieldEnd: function() {
829 var value = this.tstack.pop();
830 var fieldInfo = this.tstack.pop();
831
832 this.tstack[this.tstack.length - 1][fieldInfo.fieldId] = '{' +
833 fieldInfo.fieldType + ':' + value + '}';
834 this.tpos.pop();
835 },
836
837 /**
838 * Serializes the end of the set of fields for a struct.
839 */
840 writeFieldStop: function() {
841 //na
842 },
843
844 /**
845 * Serializes the beginning of a map collection.
846 * @param {Thrift.Type} keyType - The data type of the key.
847 * @param {Thrift.Type} valType - The data type of the value.
848 * @param {number} [size] - The number of elements in the map (ignored).
849 */
850 writeMapBegin: function(keyType, valType, size) {
851 this.tpos.push(this.tstack.length);
852 this.tstack.push([Thrift.Protocol.Type[keyType],
853 Thrift.Protocol.Type[valType], 0]);
854 },
855
856 /**
857 * Serializes the end of a map.
858 */
859 writeMapEnd: function() {
860 var p = this.tpos.pop();
861
862 if (p == this.tstack.length) {
863 return;
864 }
865
866 if ((this.tstack.length - p - 1) % 2 !== 0) {
867 this.tstack.push('');
868 }
869
870 var size = (this.tstack.length - p - 1) / 2;
871
872 this.tstack[p][this.tstack[p].length - 1] = size;
873
874 var map = '}';
875 var first = true;
876 while (this.tstack.length > p + 1) {
877 var v = this.tstack.pop();
878 var k = this.tstack.pop();
879 if (first) {
880 first = false;
881 } else {
882 map = ',' + map;
883 }
884
885 if (! isNaN(k)) { k = '"' + k + '"'; } //json "keys" need to be strings
886 map = k + ':' + v + map;
887 }
888 map = '{' + map;
889
890 this.tstack[p].push(map);
891 this.tstack[p] = '[' + this.tstack[p].join(',') + ']';
892 },
893
894 /**
895 * Serializes the beginning of a list collection.
896 * @param {Thrift.Type} elemType - The data type of the elements.
897 * @param {number} size - The number of elements in the list.
898 */
899 writeListBegin: function(elemType, size) {
900 this.tpos.push(this.tstack.length);
901 this.tstack.push([Thrift.Protocol.Type[elemType], size]);
902 },
903
904 /**
905 * Serializes the end of a list.
906 */
907 writeListEnd: function() {
908 var p = this.tpos.pop();
909
910 while (this.tstack.length > p + 1) {
911 var tmpVal = this.tstack[p + 1];
912 this.tstack.splice(p + 1, 1);
913 this.tstack[p].push(tmpVal);
914 }
915
916 this.tstack[p] = '[' + this.tstack[p].join(',') + ']';
917 },
918
919 /**
920 * Serializes the beginning of a set collection.
921 * @param {Thrift.Type} elemType - The data type of the elements.
922 * @param {number} size - The number of elements in the list.
923 */
924 writeSetBegin: function(elemType, size) {
925 this.tpos.push(this.tstack.length);
926 this.tstack.push([Thrift.Protocol.Type[elemType], size]);
927 },
928
929 /**
930 * Serializes the end of a set.
931 */
932 writeSetEnd: function() {
933 var p = this.tpos.pop();
934
935 while (this.tstack.length > p + 1) {
936 var tmpVal = this.tstack[p + 1];
937 this.tstack.splice(p + 1, 1);
938 this.tstack[p].push(tmpVal);
939 }
940
941 this.tstack[p] = '[' + this.tstack[p].join(',') + ']';
942 },
943
944 /** Serializes a boolean */
945 writeBool: function(value) {
946 this.tstack.push(value ? 1 : 0);
947 },
948
949 /** Serializes a number */
950 writeByte: function(i8) {
951 this.tstack.push(i8);
952 },
953
954 /** Serializes a number */
955 writeI16: function(i16) {
956 this.tstack.push(i16);
957 },
958
959 /** Serializes a number */
960 writeI32: function(i32) {
961 this.tstack.push(i32);
962 },
963
964 /** Serializes a number */
965 writeI64: function(i64) {
966 this.tstack.push(i64);
967 },
968
969 /** Serializes a number */
970 writeDouble: function(dbl) {
971 this.tstack.push(dbl);
972 },
973
974 /** Serializes a string */
975 writeString: function(str) {
976 // We do not encode uri components for wire transfer:
977 if (str === null) {
978 this.tstack.push(null);
979 } else {
980 // concat may be slower than building a byte buffer
981 var escapedString = '';
982 for (var i = 0; i < str.length; i++) {
983 var ch = str.charAt(i); // a single double quote: "
984 if (ch === '\"') {
985 escapedString += '\\\"'; // write out as: \"
Roger Meier52744ee2014-03-12 09:38:42 +0100986 } else if (ch === '\\') { // a single backslash
987 escapedString += '\\\\'; // write out as double backslash
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200988 } else if (ch === '\b') { // a single backspace: invisible
989 escapedString += '\\b'; // write out as: \b"
990 } else if (ch === '\f') { // a single formfeed: invisible
991 escapedString += '\\f'; // write out as: \f"
992 } else if (ch === '\n') { // a single newline: invisible
993 escapedString += '\\n'; // write out as: \n"
994 } else if (ch === '\r') { // a single return: invisible
995 escapedString += '\\r'; // write out as: \r"
996 } else if (ch === '\t') { // a single tab: invisible
997 escapedString += '\\t'; // write out as: \t"
998 } else {
999 escapedString += ch; // Else it need not be escaped
1000 }
1001 }
1002 this.tstack.push('"' + escapedString + '"');
1003 }
1004 },
1005
1006 /** Serializes a string */
1007 writeBinary: function(str) {
1008 this.writeString(str);
1009 },
1010
1011 /**
1012 @class
1013 @name AnonReadMessageBeginReturn
1014 @property {string} fname - The name of the service method.
1015 @property {Thrift.MessageType} mtype - The type of message call.
1016 @property {number} rseqid - The sequence number of the message (0 in Thrift RPC).
1017 */
1018 /**
1019 * Deserializes the beginning of a message.
1020 * @returns {AnonReadMessageBeginReturn}
1021 */
1022 readMessageBegin: function() {
1023 this.rstack = [];
1024 this.rpos = [];
1025
Roger Meier52744ee2014-03-12 09:38:42 +01001026 if (typeof JSON !== 'undefined' && typeof JSON.parse === 'function') {
1027 this.robj = JSON.parse(this.transport.readAll());
1028 } else if (typeof jQuery !== 'undefined') {
Henrique Mendonça095ddb72013-09-20 19:38:03 +02001029 this.robj = jQuery.parseJSON(this.transport.readAll());
1030 } else {
1031 this.robj = eval(this.transport.readAll());
1032 }
1033
1034 var r = {};
1035 var version = this.robj.shift();
1036
1037 if (version != Thrift.Protocol.Version) {
1038 throw 'Wrong thrift protocol version: ' + version;
1039 }
1040
1041 r.fname = this.robj.shift();
1042 r.mtype = this.robj.shift();
1043 r.rseqid = this.robj.shift();
1044
1045
1046 //get to the main obj
1047 this.rstack.push(this.robj.shift());
1048
1049 return r;
1050 },
1051
1052 /** Deserializes the end of a message. */
1053 readMessageEnd: function() {
1054 },
1055
1056 /**
1057 * Deserializes the beginning of a struct.
1058 * @param {string} [name] - The name of the struct (ignored)
1059 * @returns {object} - An object with an empty string fname property
1060 */
1061 readStructBegin: function(name) {
1062 var r = {};
1063 r.fname = '';
1064
1065 //incase this is an array of structs
1066 if (this.rstack[this.rstack.length - 1] instanceof Array) {
1067 this.rstack.push(this.rstack[this.rstack.length - 1].shift());
1068 }
1069
1070 return r;
1071 },
1072
1073 /** Deserializes the end of a struct. */
1074 readStructEnd: function() {
1075 if (this.rstack[this.rstack.length - 2] instanceof Array) {
1076 this.rstack.pop();
1077 }
1078 },
1079
1080 /**
1081 @class
1082 @name AnonReadFieldBeginReturn
1083 @property {string} fname - The name of the field (always '').
1084 @property {Thrift.Type} ftype - The data type of the field.
1085 @property {number} fid - The unique identifier of the field.
1086 */
1087 /**
1088 * Deserializes the beginning of a field.
1089 * @returns {AnonReadFieldBeginReturn}
1090 */
1091 readFieldBegin: function() {
1092 var r = {};
1093
1094 var fid = -1;
1095 var ftype = Thrift.Type.STOP;
1096
1097 //get a fieldId
1098 for (var f in (this.rstack[this.rstack.length - 1])) {
1099 if (f === null) {
1100 continue;
1101 }
1102
1103 fid = parseInt(f, 10);
1104 this.rpos.push(this.rstack.length);
1105
1106 var field = this.rstack[this.rstack.length - 1][fid];
1107
1108 //remove so we don't see it again
1109 delete this.rstack[this.rstack.length - 1][fid];
1110
1111 this.rstack.push(field);
1112
1113 break;
1114 }
1115
1116 if (fid != -1) {
1117
1118 //should only be 1 of these but this is the only
1119 //way to match a key
1120 for (var i in (this.rstack[this.rstack.length - 1])) {
1121 if (Thrift.Protocol.RType[i] === null) {
1122 continue;
1123 }
1124
1125 ftype = Thrift.Protocol.RType[i];
1126 this.rstack[this.rstack.length - 1] =
1127 this.rstack[this.rstack.length - 1][i];
1128 }
1129 }
1130
1131 r.fname = '';
1132 r.ftype = ftype;
1133 r.fid = fid;
1134
1135 return r;
1136 },
1137
1138 /** Deserializes the end of a field. */
1139 readFieldEnd: function() {
1140 var pos = this.rpos.pop();
1141
1142 //get back to the right place in the stack
1143 while (this.rstack.length > pos) {
1144 this.rstack.pop();
1145 }
1146
1147 },
1148
1149 /**
1150 @class
1151 @name AnonReadMapBeginReturn
1152 @property {Thrift.Type} ktype - The data type of the key.
1153 @property {Thrift.Type} vtype - The data type of the value.
1154 @property {number} size - The number of elements in the map.
1155 */
1156 /**
1157 * Deserializes the beginning of a map.
1158 * @returns {AnonReadMapBeginReturn}
1159 */
1160 readMapBegin: function() {
1161 var map = this.rstack.pop();
Liangliang He5d6378f2014-08-19 18:25:37 +08001162 var first = map.shift();
1163 if (first instanceof Array) {
1164 this.rstack.push(map);
1165 map = first;
1166 first = map.shift();
1167 }
Henrique Mendonça095ddb72013-09-20 19:38:03 +02001168
1169 var r = {};
Liangliang He5d6378f2014-08-19 18:25:37 +08001170 r.ktype = Thrift.Protocol.RType[first];
Henrique Mendonça095ddb72013-09-20 19:38:03 +02001171 r.vtype = Thrift.Protocol.RType[map.shift()];
1172 r.size = map.shift();
1173
1174
1175 this.rpos.push(this.rstack.length);
1176 this.rstack.push(map.shift());
1177
1178 return r;
1179 },
1180
1181 /** Deserializes the end of a map. */
1182 readMapEnd: function() {
1183 this.readFieldEnd();
1184 },
1185
1186 /**
1187 @class
1188 @name AnonReadColBeginReturn
1189 @property {Thrift.Type} etype - The data type of the element.
1190 @property {number} size - The number of elements in the collection.
1191 */
1192 /**
1193 * Deserializes the beginning of a list.
1194 * @returns {AnonReadColBeginReturn}
1195 */
1196 readListBegin: function() {
1197 var list = this.rstack[this.rstack.length - 1];
1198
1199 var r = {};
1200 r.etype = Thrift.Protocol.RType[list.shift()];
1201 r.size = list.shift();
1202
1203 this.rpos.push(this.rstack.length);
1204 this.rstack.push(list);
1205
1206 return r;
1207 },
1208
1209 /** Deserializes the end of a list. */
1210 readListEnd: function() {
1211 this.readFieldEnd();
1212 },
1213
1214 /**
1215 * Deserializes the beginning of a set.
1216 * @returns {AnonReadColBeginReturn}
1217 */
1218 readSetBegin: function(elemType, size) {
1219 return this.readListBegin(elemType, size);
1220 },
1221
1222 /** Deserializes the end of a set. */
1223 readSetEnd: function() {
1224 return this.readListEnd();
1225 },
1226
1227 /** Returns an object with a value property set to
1228 * False unless the next number in the protocol buffer
Konrad Grochowski3b5dacb2014-11-24 10:55:31 +01001229 * is 1, in which case the value property is True */
Henrique Mendonça095ddb72013-09-20 19:38:03 +02001230 readBool: function() {
1231 var r = this.readI32();
1232
1233 if (r !== null && r.value == '1') {
1234 r.value = true;
1235 } else {
1236 r.value = false;
1237 }
1238
1239 return r;
1240 },
1241
1242 /** Returns the an object with a value property set to the
1243 next value found in the protocol buffer */
1244 readByte: function() {
1245 return this.readI32();
1246 },
1247
1248 /** Returns the an object with a value property set to the
1249 next value found in the protocol buffer */
1250 readI16: function() {
1251 return this.readI32();
1252 },
1253
1254 /** Returns the an object with a value property set to the
1255 next value found in the protocol buffer */
1256 readI32: function(f) {
1257 if (f === undefined) {
1258 f = this.rstack[this.rstack.length - 1];
1259 }
1260
1261 var r = {};
1262
1263 if (f instanceof Array) {
1264 if (f.length === 0) {
1265 r.value = undefined;
1266 } else {
1267 r.value = f.shift();
1268 }
1269 } else if (f instanceof Object) {
1270 for (var i in f) {
1271 if (i === null) {
1272 continue;
1273 }
1274 this.rstack.push(f[i]);
1275 delete f[i];
1276
1277 r.value = i;
1278 break;
1279 }
1280 } else {
1281 r.value = f;
1282 this.rstack.pop();
1283 }
1284
1285 return r;
1286 },
1287
1288 /** Returns the an object with a value property set to the
1289 next value found in the protocol buffer */
1290 readI64: function() {
1291 return this.readI32();
1292 },
1293
1294 /** Returns the an object with a value property set to the
1295 next value found in the protocol buffer */
1296 readDouble: function() {
1297 return this.readI32();
1298 },
1299
1300 /** Returns the an object with a value property set to the
1301 next value found in the protocol buffer */
1302 readString: function() {
1303 var r = this.readI32();
1304 return r;
1305 },
1306
1307 /** Returns the an object with a value property set to the
1308 next value found in the protocol buffer */
1309 readBinary: function() {
1310 return this.readString();
1311 },
1312
1313 /**
Jens Geyer329d59a2014-06-19 22:11:53 +02001314 * Method to arbitrarily skip over data */
Henrique Mendonça095ddb72013-09-20 19:38:03 +02001315 skip: function(type) {
Jens Geyer329d59a2014-06-19 22:11:53 +02001316 var ret, i;
1317 switch (type) {
1318 case Thrift.Type.STOP:
1319 return null;
1320
1321 case Thrift.Type.BOOL:
1322 return this.readBool();
1323
1324 case Thrift.Type.BYTE:
1325 return this.readByte();
1326
1327 case Thrift.Type.I16:
1328 return this.readI16();
1329
1330 case Thrift.Type.I32:
1331 return this.readI32();
1332
1333 case Thrift.Type.I64:
1334 return this.readI64();
1335
1336 case Thrift.Type.DOUBLE:
1337 return this.readDouble();
1338
1339 case Thrift.Type.STRING:
1340 return this.readString();
1341
1342 case Thrift.Type.STRUCT:
1343 this.readStructBegin();
1344 while (true) {
1345 ret = this.readFieldBegin();
1346 if (ret.ftype == Thrift.Type.STOP) {
1347 break;
1348 }
1349 this.skip(ret.ftype);
1350 this.readFieldEnd();
1351 }
1352 this.readStructEnd();
1353 return null;
1354
1355 case Thrift.Type.MAP:
1356 ret = this.readMapBegin();
1357 for (i = 0; i < ret.size; i++) {
1358 if (i > 0) {
1359 if (this.rstack.length > this.rpos[this.rpos.length - 1] + 1) {
1360 this.rstack.pop();
1361 }
1362 }
1363 this.skip(ret.ktype);
1364 this.skip(ret.vtype);
1365 }
1366 this.readMapEnd();
1367 return null;
1368
1369 case Thrift.Type.SET:
1370 ret = this.readSetBegin();
1371 for (i = 0; i < ret.size; i++) {
1372 this.skip(ret.etype);
1373 }
1374 this.readSetEnd();
1375 return null;
1376
1377 case Thrift.Type.LIST:
1378 ret = this.readListBegin();
1379 for (i = 0; i < ret.size; i++) {
1380 this.skip(ret.etype);
1381 }
1382 this.readListEnd();
1383 return null;
1384 }
Henrique Mendonça095ddb72013-09-20 19:38:03 +02001385 }
1386};
henrique5ba91f22013-12-20 21:13:13 +01001387
1388
1389/**
1390 * Initializes a MutilplexProtocol Implementation as a Wrapper for Thrift.Protocol
1391 * @constructor
1392 */
1393Thrift.MultiplexProtocol = function (srvName, trans, strictRead, strictWrite) {
1394 Thrift.Protocol.call(this, trans, strictRead, strictWrite);
1395 this.serviceName = srvName;
1396};
1397Thrift.inherits(Thrift.MultiplexProtocol, Thrift.Protocol, 'multiplexProtocol');
1398
1399/** Override writeMessageBegin method of prototype*/
1400Thrift.MultiplexProtocol.prototype.writeMessageBegin = function (name, type, seqid) {
1401
1402 if (type === Thrift.MessageType.CALL || type === Thrift.MessageType.ONEWAY) {
1403 Thrift.Protocol.prototype.writeMessageBegin.call(this, this.serviceName + ":" + name, type, seqid);
1404 } else {
1405 Thrift.Protocol.prototype.writeMessageBegin.call(this, name, type, seqid);
1406 }
1407};
1408
1409Thrift.Multiplexer = function () {
1410 this.seqid = 0;
1411};
1412
1413/** Instantiates a multiplexed client for a specific service
1414 * @constructor
1415 * @param {String} serviceName - The transport to serialize to/from.
1416 * @param {Thrift.ServiceClient} SCl - The Service Client Class
1417 * @param {Thrift.Transport} transport - Thrift.Transport instance which provides remote host:port
1418 * @example
1419 * var mp = new Thrift.Multiplexer();
1420 * var transport = new Thrift.Transport("http://localhost:9090/foo.thrift");
1421 * var protocol = new Thrift.Protocol(transport);
1422 * var client = mp.createClient('AuthService', AuthServiceClient, transport);
1423*/
1424Thrift.Multiplexer.prototype.createClient = function (serviceName, SCl, transport) {
1425 if (SCl.Client) {
1426 SCl = SCl.Client;
1427 }
1428 var self = this;
1429 SCl.prototype.new_seqid = function () {
1430 self.seqid += 1;
1431 return self.seqid;
1432 };
1433 var client = new SCl(new Thrift.MultiplexProtocol(serviceName, transport));
1434
1435 return client;
1436};
1437
henriquea2de4102014-02-07 14:12:56 +01001438
henrique2a7dccc2014-03-07 22:16:51 +01001439