-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAmqpClient.js
More file actions
2628 lines (2627 loc) · 98.6 KB
/
AmqpClient.js
File metadata and controls
2628 lines (2627 loc) · 98.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Copyright (c) 2007-2015, Kaazing Corporation. All rights reserved.
*/
function URI(h){h=h||"";
var b=0;
var e=h.indexOf("://");
if(e!=-1){this.scheme=h.slice(0,e);
b=e+3;
var d=h.indexOf("/",b);
if(d==-1){d=h.length;
h+="/"
}var f=h.slice(b,d);
this.authority=f;
b=d;
this.host=f;
var c=f.indexOf(":");
if(c!=-1){this.host=f.slice(0,c);
this.port=parseInt(f.slice(c+1),10);
if(isNaN(this.port)){throw new Error("Invalid URI syntax")
}}}var g=h.indexOf("?",b);
if(g!=-1){this.path=h.slice(b,g);
b=g+1
}var a=h.indexOf("#",b);
if(a!=-1){if(g!=-1){this.query=h.slice(b,a)
}else{this.path=h.slice(b,a)
}b=a+1;
this.fragment=h.slice(b)
}else{if(g!=-1){this.query=h.slice(b)
}else{this.path=h.slice(b)
}}}(function(){var a=URI.prototype;
a.toString=function(){var e=[];
var d=this.scheme;
if(d!==undefined){e.push(d);
e.push("://");
e.push(this.host);
var c=this.port;
if(c!==undefined){e.push(":");
e.push(c.toString())
}}if(this.path!==undefined){e.push(this.path)
}if(this.query!==undefined){e.push("?");
e.push(this.query)
}if(this.fragment!==undefined){e.push("#");
e.push(this.fragment)
}return e.join("")
};
var b={http:80,ws:80,https:443,wss:443};
URI.replaceProtocol=function(c,e){var d=c.indexOf("://");
if(d>0){return e+c.substr(d)
}else{return""
}}
})();
ByteOrder=function(){};
(function(){var g=ByteOrder.prototype;
g.toString=function(){throw new Error("Abstract")
};
var d=function(n){return(n&255)
};
var j=function(n){return(n&128)?(n|-256):n
};
var c=function(n){return[((n>>8)&255),(n&255)]
};
var m=function(n,o){return(j(n)<<8)|(o&255)
};
var b=function(n,o){return((n&255)<<8)|(o&255)
};
var e=function(n,o,p){return((n&255)<<16)|((o&255)<<8)|(p&255)
};
var k=function(n){return[((n>>16)&255),((n>>8)&255),(n&255)]
};
var l=function(n,o,p){return((n&255)<<16)|((o&255)<<8)|(p&255)
};
var f=function(n){return[((n>>24)&255),((n>>16)&255),((n>>8)&255),(n&255)]
};
var h=function(q,n,o,p){return(j(q)<<24)|((n&255)<<16)|((o&255)<<8)|(p&255)
};
var a=function(t,n,p,r){var o=b(t,n);
var q=b(p,r);
return(o*65536+q)
};
ByteOrder.BIG_ENDIAN=(function(){var o=function(){};
o.prototype=new ByteOrder();
var n=o.prototype;
n._toUnsignedByte=d;
n._toByte=j;
n._fromShort=c;
n._toShort=m;
n._toUnsignedShort=b;
n._toUnsignedMediumInt=e;
n._fromMediumInt=k;
n._toMediumInt=l;
n._fromInt=f;
n._toInt=h;
n._toUnsignedInt=a;
n.toString=function(){return"<ByteOrder.BIG_ENDIAN>"
};
return new o()
})();
ByteOrder.LITTLE_ENDIAN=(function(){var o=function(){};
o.prototype=new ByteOrder();
var n=o.prototype;
n._toByte=j;
n._toUnsignedByte=d;
n._fromShort=function(p){return c(p).reverse()
};
n._toShort=function(p,q){return m(q,p)
};
n._toUnsignedShort=function(p,q){return b(q,p)
};
n._toUnsignedMediumInt=function(p,q,r){return e(r,q,p)
};
n._fromMediumInt=function(p){return k(p).reverse()
};
n._toMediumInt=function(t,u,v,p,q,r){return l(r,q,p,v,u,t)
};
n._fromInt=function(p){return f(p).reverse()
};
n._toInt=function(t,p,q,r){return h(r,q,p,t)
};
n._toUnsignedInt=function(t,p,q,r){return a(r,q,p,t)
};
n.toString=function(){return"<ByteOrder.LITTLE_ENDIAN>"
};
return new o()
})()
})();
function ByteBuffer(a){this.array=a||[];
this._mark=-1;
this.limit=this.capacity=this.array.length;
this.order=ByteOrder.BIG_ENDIAN
}(function(){ByteBuffer.allocate=function(g){var h=new ByteBuffer();
h.capacity=g;
h.limit=g;
return h
};
ByteBuffer.wrap=function(g){return new ByteBuffer(g)
};
var b=ByteBuffer.prototype;
b.autoExpand=true;
b.capacity=0;
b.position=0;
b.limit=0;
b.order=ByteOrder.BIG_ENDIAN;
b.array=[];
b.mark=function(){this._mark=this.position;
return this
};
b.reset=function(){var g=this._mark;
if(g<0){throw new Error("Invalid mark")
}this.position=g;
return this
};
b.compact=function(){this.array.splice(0,this.position);
this.limit-=this.position;
this.position=0;
return this
};
b.duplicate=function(){var g=new ByteBuffer(this.array);
g.position=this.position;
g.limit=this.limit;
g.capacity=this.capacity;
return g
};
b.fill=function(g){e(this,g);
while(g-->0){this.put(0)
}return this
};
b.fillWith=function(g,h){e(this,h);
while(h-->0){this.put(g)
}return this
};
b.indexOf=function(g){var h=this.limit;
var k=this.array;
for(var j=this.position;
j<h;
j++){if(k[j]==g){return j
}}return -1
};
b.put=function(g){e(this,1);
this.array[this.position++]=g&255;
return this
};
b.putAt=function(h,g){c(this,h,1);
this.array[h]=g&255;
return this
};
b.putUnsigned=function(g){e(this,1);
this.array[this.position++]=g&255;
return this
};
b.putUnsignedAt=function(h,g){c(this,h,1);
this.array[h]=g&255;
return this
};
b.putShort=function(g){e(this,2);
a(this,this.position,this.order._fromShort(g));
this.position+=2;
return this
};
b.putShortAt=function(h,g){c(this,h,2);
a(this,h,this.order._fromShort(g));
return this
};
b.putUnsignedShort=function(g){e(this,2);
a(this,this.position,this.order._fromShort(g&65535));
this.position+=2;
return this
};
b.putUnsignedShortAt=function(h,g){c(this,h,2);
a(this,h,this.order._fromShort(g&65535));
return this
};
b.putMediumInt=function(g){e(this,3);
this.putMediumIntAt(this.position,g);
this.position+=3;
return this
};
b.putMediumIntAt=function(h,g){this.putBytesAt(h,this.order._fromMediumInt(g));
return this
};
b.putInt=function(g){e(this,4);
a(this,this.position,this.order._fromInt(g));
this.position+=4;
return this
};
b.putIntAt=function(h,g){c(this,h,4);
a(this,h,this.order._fromInt(g));
return this
};
b.putUnsignedInt=function(g){e(this,4);
this.putUnsignedIntAt(this.position,g&4294967295);
this.position+=4;
return this
};
b.putUnsignedIntAt=function(h,g){c(this,h,4);
this.putIntAt(h,g&4294967295);
return this
};
b.putString=function(g,h){h.encode(g,this);
return this
};
b.putPrefixedString=function(h,j,k){if(typeof(k)==="undefined"||typeof(k.encode)==="undefined"){throw new Error("ByteBuffer.putPrefixedString: character set parameter missing")
}if(h===0){return this
}e(this,h);
var g=j.length;
switch(h){case 1:this.put(g);
break;
case 2:this.putShort(g);
break;
case 4:this.putInt(g);
break
}k.encode(j,this);
return this
};
function a(k,h,g){var l=k.array;
for(var j=0;
j<g.length;
j++){l[j+h]=g[j]&255
}}b.putBytes=function(g){e(this,g.length);
a(this,this.position,g);
this.position+=g.length;
return this
};
b.putBytesAt=function(h,g){c(this,h,g.length);
a(this,h,g);
return this
};
b.putByteArray=function(g){e(this,g.byteLength);
var h=new Uint8Array(g);
for(var j=0;
j<h.byteLength;
j++){this.putAt(this.position+j,h[j]&255)
}this.position+=g.byteLength;
return this
};
b.putBuffer=function(h){var g=h.remaining();
e(this,g);
var m=h.array;
var l=h.position;
var k=this.position;
for(var j=0;
j<g;
j++){this.array[j+k]=m[j+l]
}this.position+=g;
return this
};
b.putBufferAt=function(j,h){var g=h.remaining();
e(this,g);
var n=h.array;
var m=h.position;
var l=this.position;
for(var k=0;
k<g;
k++){this.array[k+l]=n[k+m]
}return this
};
b.get=function(){f(this,1);
return this.order._toByte(this.array[this.position++])
};
b.getAt=function(g){d(this,g,1);
return this.order._toByte(this.array[g])
};
b.getUnsigned=function(){f(this,1);
var g=this.order._toUnsignedByte(this.array[this.position++]);
return g
};
b.getUnsignedAt=function(g){d(this,g,1);
return this.order._toUnsignedByte(this.array[g])
};
b.getBytes=function(j){f(this,j);
var g=new Array();
for(var h=0;
h<j;
h++){g.push(this.order._toByte(this.array[h+this.position]))
}this.position+=j;
return g
};
b.getBytesAt=function(h,k){d(this,h,k);
var g=new Array();
var l=this.array;
for(var j=0;
j<k;
j++){g.push(l[j+h])
}return g
};
b.getBlob=function(h){var g=this.array.slice(this.position,h);
this.position+=h;
return BlobUtils.fromNumberArray(g)
};
b.getBlobAt=function(h,j){var g=this.getBytesAt(h,j);
return BlobUtils.fromNumberArray(g)
};
b.getArrayBuffer=function(h){var g=new Uint8Array(h);
g.set(this.array.slice(this.position,h));
this.position+=h;
return g.buffer
};
b.getShort=function(){f(this,2);
var g=this.getShortAt(this.position);
this.position+=2;
return g
};
b.getShortAt=function(g){d(this,g,2);
var h=this.array;
return this.order._toShort(h[g++],h[g++])
};
b.getUnsignedShort=function(){f(this,2);
var g=this.getUnsignedShortAt(this.position);
this.position+=2;
return g
};
b.getUnsignedShortAt=function(g){d(this,g,2);
var h=this.array;
return this.order._toUnsignedShort(h[g++],h[g++])
};
b.getUnsignedMediumInt=function(){var g=this.array;
return this.order._toUnsignedMediumInt(g[this.position++],g[this.position++],g[this.position++])
};
b.getMediumInt=function(){var g=this.getMediumIntAt(this.position);
this.position+=3;
return g
};
b.getMediumIntAt=function(g){var h=this.array;
return this.order._toMediumInt(h[g++],h[g++],h[g++])
};
b.getInt=function(){f(this,4);
var g=this.getIntAt(this.position);
this.position+=4;
return g
};
b.getIntAt=function(g){d(this,g,4);
var h=this.array;
return this.order._toInt(h[g++],h[g++],h[g++],h[g++])
};
b.getUnsignedInt=function(){f(this,4);
var g=this.getUnsignedIntAt(this.position);
this.position+=4;
return g
};
b.getUnsignedIntAt=function(g){d(this,g,4);
var h=this.array;
return this.order._toUnsignedInt(h[g++],h[g++],h[g++],h[g++]);
return val
};
b.getPrefixedString=function(h,j){var g=0;
switch(h||2){case 1:g=this.getUnsigned();
break;
case 2:g=this.getUnsignedShort();
break;
case 4:g=this.getInt();
break
}if(g===0){return""
}var k=this.limit;
try{this.limit=this.position+g;
return j.decode(this)
}finally{this.limit=k
}};
b.getString=function(g){try{return g.decode(this)
}finally{this.position=this.limit
}};
b.slice=function(){return new ByteBuffer(this.array.slice(this.position,this.limit))
};
b.flip=function(){this.limit=this.position;
this.position=0;
this._mark=-1;
return this
};
b.rewind=function(){this.position=0;
this._mark=-1;
return this
};
b.clear=function(){this.position=0;
this.limit=this.capacity;
this._mark=-1;
return this
};
b.remaining=function(){return(this.limit-this.position)
};
b.hasRemaining=function(){return(this.limit>this.position)
};
b.skip=function(g){this.position+=g;
return this
};
b.getHexDump=function(){var m=this.array;
var l=this.position;
var g=this.limit;
if(l==g){return"empty"
}var k=[];
for(var h=l;
h<g;
h++){var j=(m[h]||0).toString(16);
if(j.length==1){j="0"+j
}k.push(j)
}return k.join(" ")
};
b.toString=b.getHexDump;
b.expand=function(g){return this.expandAt(this.position,g)
};
b.expandAt=function(h,j){var g=h+j;
if(g>this.capacity){this.capacity=g
}if(g>this.limit){this.limit=g
}return this
};
function e(h,g){if(h.autoExpand){h.expand(g)
}return h
}function f(j,h){var g=j.position+h;
if(g>j.limit){throw new Error("Buffer underflow")
}return j
}function d(k,h,j){var g=h+j;
if(h<0||g>k.limit){throw new Error("Index out of bounds")
}return k
}function c(k,h,j){var g=h+j;
if(h<0||g>k.limit){throw new Error("Index out of bounds")
}return k
}})();
function Charset(){}(function(){var a=Charset.prototype;
a.decode=function(b){};
a.encode=function(c,b){};
Charset.UTF8=(function(){function d(){}d.prototype=new Charset();
var c=d.prototype;
c.decode=function(f){var k=f.remaining();
var n=k<10000;
var r=[];
var m=f.array;
var l=f.position;
var j=l+k;
var u,q,p,o;
for(var h=l;
h<j;
h++){u=(m[h]&255);
var e=b(u);
var g=j-h;
if(g<e){break
}var t=null;
switch(e){case 1:t=u;
break;
case 2:h++;
q=(m[h]&255);
t=((u&31)<<6)|(q&63);
break;
case 3:h++;
q=(m[h]&255);
h++;
p=(m[h]&255);
t=((u&15)<<12)|((q&63)<<6)|(p&63);
break;
case 4:h++;
q=(m[h]&255);
h++;
p=(m[h]&255);
h++;
o=(m[h]&255);
t=((u&7)<<18)|((q&63)<<12)|((p&63)<<6)|(o&63);
break
}if(n){r.push(t)
}else{r.push(String.fromCharCode(t))
}}if(n){return String.fromCharCode.apply(null,r)
}else{return r.join("")
}};
c.encode=function(j,f){var h=f.position;
var l=h;
var k=f.array;
for(var g=0;
g<j.length;
g++){var e=j.charCodeAt(g);
if(e<128){k[h++]=e
}else{if(e<2048){k[h++]=(e>>6)|192;
k[h++]=(e&63)|128
}else{if(e<65536){k[h++]=(e>>12)|224;
k[h++]=((e>>6)&63)|128;
k[h++]=(e&63)|128
}else{if(e<1114112){k[h++]=(e>>18)|240;
k[h++]=((e>>12)&63)|128;
k[h++]=((e>>6)&63)|128;
k[h++]=(e&63)|128
}else{throw new Error("Invalid UTF-8 string")
}}}}}f.position=h;
f.expandAt(h,h-l)
};
c.encodeAsByteArray=function(h){var f=new Array();
for(var g=0;
g<h.length;
g++){var e=h.charCodeAt(g);
if(e<128){f.push(e)
}else{if(e<2048){f.push((e>>6)|192);
f.push((e&63)|128)
}else{if(e<65536){f.push((e>>12)|224);
f.push(((e>>6)&63)|128);
f.push((e&63)|128)
}else{if(e<1114112){f.push((e>>18)|240);
f.push(((e>>12)&63)|128);
f.push(((e>>6)&63)|128);
f.push((e&63)|128)
}else{throw new Error("Invalid UTF-8 string")
}}}}}return f
};
c.encodeByteArray=function(j){var h=j.length;
var f=[];
for(var g=0;
g<h;
g++){var e=j[g];
if(e<128){f.push(e)
}else{if(e<2048){f.push((e>>6)|192);
f.push((e&63)|128)
}else{if(e<65536){f.push((e>>12)|224);
f.push(((e>>6)&63)|128);
f.push((e&63)|128)
}else{if(e<1114112){f.push((e>>18)|240);
f.push(((e>>12)&63)|128);
f.push(((e>>6)&63)|128);
f.push((e&63)|128)
}else{throw new Error("Invalid UTF-8 string")
}}}}}return String.fromCharCode.apply(null,f)
};
c.encodeArrayBuffer=function(k){var g=new Uint8Array(k);
var j=g.length;
var f=[];
for(var h=0;
h<j;
h++){var e=g[h];
if(e<128){f.push(e)
}else{if(e<2048){f.push((e>>6)|192);
f.push((e&63)|128)
}else{if(e<65536){f.push((e>>12)|224);
f.push(((e>>6)&63)|128);
f.push((e&63)|128)
}else{if(e<1114112){f.push((e>>18)|240);
f.push(((e>>12)&63)|128);
f.push(((e>>6)&63)|128);
f.push((e&63)|128)
}else{throw new Error("Invalid UTF-8 string")
}}}}}return String.fromCharCode.apply(null,f)
};
c.toByteArray=function(h){var l=[];
var o,m,k,j;
var f=h.length;
for(var g=0;
g<f;
g++){o=(h.charCodeAt(g)&255);
var e=b(o);
var n=null;
if(e+g>f){break
}switch(e){case 1:n=o;
break;
case 2:g++;
m=(h.charCodeAt(g)&255);
n=((o&31)<<6)|(m&63);
break;
case 3:g++;
m=(h.charCodeAt(g)&255);
g++;
k=(h.charCodeAt(g)&255);
n=((o&15)<<12)|((m&63)<<6)|(k&63);
break;
case 4:g++;
m=(h.charCodeAt(g)&255);
g++;
k=(h.charCodeAt(g)&255);
g++;
j=(h.charCodeAt(g)&255);
n=((o&7)<<18)|((m&63)<<12)|((k&63)<<6)|(j&63);
break
}l.push(n&255)
}return l
};
function b(e){if((e&128)===0){return 1
}if((e&32)===0){return 2
}if((e&16)===0){return 3
}if((e&8)===0){return 4
}throw new Error("Invalid UTF-8 bytes")
}return new d()
})()
})();
var KzLogger=function(a){this._name=a;
this._level=KzLogger.Level.INFO
};
(function(){KzLogger.Level={OFF:8,SEVERE:7,WARNING:6,INFO:5,CONFIG:4,FINE:3,FINER:2,FINEST:1,ALL:0};
var g;
var j=document.getElementsByTagName("meta");
for(var d=0;
d<j.length;
d++){if(j[d].name==="kaazing:logging"){g=j[d].content;
break
}}KzLogger._logConf={};
if(g){var f=g.split(",");
for(var d=0;
d<f.length;
d++){var b=f[d].split("=");
KzLogger._logConf[b[0]]=b[1]
}}var a={};
KzLogger.getLogger=function(l){var k=a[l];
if(k===undefined){k=new KzLogger(l);
a[l]=k
}return k
};
var e=KzLogger.prototype;
e.setLevel=function(k){if(k&&k>=KzLogger.Level.ALL&&k<=KzLogger.Level.OFF){this._level=k
}};
e.isLoggable=function(m){for(var l in KzLogger._logConf){if(KzLogger._logConf.hasOwnProperty(l)){if(this._name.match(l)){var k=KzLogger._logConf[l];
if(k){return(KzLogger.Level[k]<=m)
}}}}return(this._level<=m)
};
var h=function(){};
var c={};
c[KzLogger.Level.OFF]=h;
c[KzLogger.Level.SEVERE]=(window.console)?(console.error||console.log||h):h;
c[KzLogger.Level.WARNING]=(window.console)?(console.warn||console.log||h):h;
c[KzLogger.Level.INFO]=(window.console)?(console.info||console.log||h):h;
c[KzLogger.Level.CONFIG]=(window.console)?(console.info||console.log||h):h;
c[KzLogger.Level.FINE]=(window.console)?(console.debug||console.log||h):h;
c[KzLogger.Level.FINER]=(window.console)?(console.debug||console.log||h):h;
c[KzLogger.Level.FINEST]=(window.console)?(console.debug||console.log||h):h;
c[KzLogger.Level.ALL]=(window.console)?(console.log||h):h;
e.config=function(l,k){this.log(KzLogger.Level.CONFIG,l,k)
};
e.entering=function(m,k,n){if(this.isLoggable(KzLogger.Level.FINER)){if(browser=="chrome"||browser=="safari"){m=console
}var l=c[KzLogger.Level.FINER];
if(n){if(typeof(l)=="object"){l("ENTRY "+k,n)
}else{l.call(m,"ENTRY "+k,n)
}}else{if(typeof(l)=="object"){l("ENTRY "+k)
}else{l.call(m,"ENTRY "+k)
}}}};
e.exiting=function(n,k,m){if(this.isLoggable(KzLogger.Level.FINER)){var l=c[KzLogger.Level.FINER];
if(browser=="chrome"||browser=="safari"){n=console
}if(m){if(typeof(l)=="object"){l("RETURN "+k,m)
}else{l.call(n,"RETURN "+k,m)
}}else{if(typeof(l)=="object"){l("RETURN "+k)
}else{l.call(n,"RETURN "+k)
}}}};
e.fine=function(l,k){this.log(KzLogger.Level.FINE,l,k)
};
e.finer=function(l,k){this.log(KzLogger.Level.FINER,l,k)
};
e.finest=function(l,k){this.log(KzLogger.Level.FINEST,l,k)
};
e.info=function(l,k){this.log(KzLogger.Level.INFO,l,k)
};
e.log=function(n,m,l){if(this.isLoggable(n)){var k=c[n];
if(browser=="chrome"||browser=="safari"){m=console
}if(typeof(k)=="object"){k(l)
}else{k.call(m,l)
}}};
e.severe=function(l,k){this.log(KzLogger.Level.SEVERE,l,k)
};
e.warning=function(l,k){this.log(KzLogger.Level.WARNING,l,k)
}
})();
var ULOG=KzLogger.getLogger("com.kaazing.gateway.client.loader.Utils");
var getMetaValue=function(d){ULOG.entering(this,"Utils.getMetaValue",d);
var b=document.getElementsByTagName("meta");
for(var c=0;
c<b.length;
c++){if(b[c].name===d){var a=b[c].content;
ULOG.exiting(this,"Utils.getMetaValue",a);
return a
}}ULOG.exiting(this,"Utils.getMetaValue")
};
var arrayCopy=function(c){ULOG.entering(this,"Utils.arrayCopy",c);
var a=[];
for(var b=0;
b<c.length;
b++){a.push(c[b])
}return a
};
var arrayFilter=function(e,d){ULOG.entering(this,"Utils.arrayFilter",{array:e,callback:d});
var a=[];
for(var c=0;
c<e.length;
c++){var b=e[c];
if(d(b)){a.push(e[c])
}}return a
};
var indexOf=function(c,a){ULOG.entering(this,"Utils.indexOf",{array:c,searchElement:a});
for(var b=0;
b<c.length;
b++){if(c[b]==a){ULOG.exiting(this,"Utils.indexOf",b);
return b
}}ULOG.exiting(this,"Utils.indexOf",-1);
return -1
};
var decodeByteString=function(f){ULOG.entering(this,"Utils.decodeByteString",f);
var b=[];
for(var e=0;
e<f.length;
e++){b.push(f.charCodeAt(e)&255)
}var d=new ByteBuffer(b);
var c=getStringUnterminated(d,Charset.UTF8);
ULOG.exiting(this,"Utils.decodeByteString",c);
return c
};
var decodeArrayBuffer=function(f){ULOG.entering(this,"Utils.decodeArrayBuffer",f);
var c=new Uint8Array(f);
var b=[];
for(var d=0;
d<c.length;
d++){b.push(c[d])
}var c=new ByteBuffer(b);
var e=getStringUnterminated(c,Charset.UTF8);
ULOG.exiting(this,"Utils.decodeArrayBuffer",e);
return e
};
var decodeArrayBuffer2ByteBuffer=function(e){ULOG.entering(this,"Utils.decodeArrayBuffer2ByteBuffer");
var c=new Uint8Array(e);
var b=[];
for(var d=0;
d<c.length;
d++){b.push(c[d])
}ULOG.exiting(this,"Utils.decodeArrayBuffer2ByteBuffer");
return new ByteBuffer(b)
};
var ESCAPE_CHAR=String.fromCharCode(127);
var NULL=String.fromCharCode(0);
var LINEFEED="\n";
var encodeEscapedByteString=function(d){ULOG.entering(this,"Utils.encodeEscapedByte",d);
var b=[];
while(d.remaining()){var f=d.getUnsigned();
var e=String.fromCharCode(f);
switch(e){case ESCAPE_CHAR:b.push(ESCAPE_CHAR);
b.push(ESCAPE_CHAR);
break;
case NULL:b.push(ESCAPE_CHAR);
b.push("0");
break;
case LINEFEED:b.push(ESCAPE_CHAR);
b.push("n");
break;
default:b.push(e)
}}var c=b.join("");
ULOG.exiting(this,"Utils.encodeEscapedBytes",c);
return c
};
var encodeByteString=function(c,b){ULOG.entering(this,"Utils.encodeByteString",{buf:c,requiresEscaping:b});
if(b){return encodeEscapedByteString(c)
}else{var h=c.array;
var l=(c.position==0&&c.limit==h.length)?h:c.getBytes(c.remaining());
var g=!(XMLHttpRequest.prototype.sendAsBinary);
for(var e=l.length-1;
e>=0;
e--){var f=l[e];
if(f==0&&g){l[e]=256
}else{if(f<0){l[e]=f&255
}}}var j=0;
var k=[];
do{var a=Math.min(l.length-j,10000);
partOfBytes=l.slice(j,j+a);
j+=a;
k.push(String.fromCharCode.apply(null,partOfBytes))
}while(j<l.length);
var d=k.join("");
if(l===h){for(var e=l.length-1;
e>=0;
e--){var f=l[e];
if(f==256){l[e]=0
}}}ULOG.exiting(this,"Utils.encodeByteString",d);
return d
}};
var getStringUnterminated=function(b,c){var a=b.position;
var d=b.limit;
var e=b.array;
while(a<d){a++
}try{b.limit=a;
return c.decode(b)
}finally{if(a!=d){b.limit=d;
b.position=a+1
}}};
var LOADER_BASE_NAME="AmqpClient";
var EventDispatcher=function(){};
(function(){var a=EventDispatcher.prototype;
a._initEventDispatcher=function(){this._eventListeners={}
};
a.addEventListener=function(c,d){var b=this._eventListeners[c];
if(b){b.push(d)
}else{this._eventListeners[c]=[d]
}};
a.removeEventListener=function(e,f){var d=this._eventListeners[e];
if(d){var b=[];
for(var c=0;
c<d.length;
c++){if(d[c]!==f){b.push(d[c])
}}this._eventListeners[e]=new Listeners
}};
a.hasEventListener=function(c){var b=this._eventListeners[c];
return Boolean(b)
};
a.dispatchEvent=function(d){var c=this._eventListeners[d.type];
if(c){for(var b=0;
b<c.length;
b++){c[b](d)
}}if(this["on"+d.type]){this["on"+d.type](d)
}}
})();
var AmqpClient=function(a){if(!a||!(a instanceof AmqpClientFactory)){throw new Error("AmqpClient: Required parameter 'factory' must be an instance of AmqpClientFactory")
}this._amqpClientFactory=a;
this._options={};
this._readyState=0;
this._init()
};
(function(){var w=function(aB){this.context=aB;
this.states={}
};
(function(){var aB=w.prototype;
var aC=function aC(){};
aB.enterState=function(aH,aE,aF){if(this.currentState){this.currentState.exitBehavior(this.context,aE,aF,aH)
}var aG=this.states[aH];
this.currentState=aG;
try{aG.entryBehavior(this.context,aE,aF,aH)
}catch(aI){var aD=new Error("Could not call behavior for state "+aG.stateName+"\n\n"+aI.message);
aD.innerException=aI;
throw (aD)
}};
aB.addState=function(aM,aF,aK,aE){var aD={};
aD.stateName=aM;
aD.entryBehavior=aK||aC;
aD.exitBehavior=aE||aC;
this.states[aM]=(aD);
aD.rules={};
var aL=aF||[];
for(var aH=0;
aH<aL.length;
aH++){var aI=aL[aH];
for(var aG=0;
aG<aI.inputs.length;
aG++){var aJ=aI.inputs[aG];
aD.rules[aJ]=aI.targetState
}}};
aB.feedInput=function(aD,aE){var aG=this.currentState;
if(aG.rules[aD]){var aH=this;
var aF=function(){aH.enterState(aG.rules[aD],aD,aE)
};
aF();
return true
}else{return false
}}
})();
var e=function(){};
(function(){e.prototype=new EventDispatcher();
var aE=e.prototype;
var aB=function aB(){};
var aD=function aD(aG){throw aG
};
aE._stateMachine=null;
aE.onerror=function(aG){};
aE._actions=[];
aE._processActions=function aC(){if(!this._actions.length){return
}var aI=this._actions[0];
var aH=this._stateMachine.feedInput(aI.actionName+"Action",aI);
if(aH){var aG=this;
setTimeout(function(){try{aI.func.apply(aG,aI.args)
}catch(aJ){aI.error(aJ)
}},0);
this._actions.shift()
}};
aE._enqueueAction=function aF(aH,aL,aJ,aG,aI){var aM={};
aM.actionName=aH||"";
aM.func=aL||aB;
aM.args=aJ||null;
aM.continuation=aG||aB;
aM.error=aI||aD;
this._actions.push(aM);
var aK=this;
var aL=function(){aK._processActions()
};
setTimeout(aL,0)
};
aE._initAsyncClient=function(){this._initEventDispatcher();
this._stateMachine=new w(this);
this._actions=[];
this._buffer=null;
this._socket=null
};
aE._send=null;
aE._readHandler=null
})();
var N={};
N.FRAME_METHOD={value:1,message:""};
N.FRAME_HEADER={value:2,message:""};
N.FRAME_BODY={value:3,message:""};
N.FRAME_HEARTBEAT={value:8,message:""};
N.FRAME_MIN_SIZE={value:4096,message:""};
N.FRAME_END={value:206,message:""};
N.REPLY_SUCCESS={value:200,message:"Indicates that the method completed successfully. This reply code is reserved for future use - the current protocol design does not use positive confirmation and reply codes are sent only in case of an error."};
N.CONTENT_TOO_LARGE={value:311,message:"The client attempted to transfer content larger than the server could accept at the present time. The client may retry at a later time."};
N.NO_CONSUMERS={value:313,message:"When the exchange cannot deliver to a consumer when the immediate flag is set. As a result of pending data on the queue or the absence of any consumers of the queue."};
N.CONNECTION_FORCED={value:320,message:"An operator intervened to close the connection for some reason. The client may retry at some later date."};
N.INVALID_PATH={value:402,message:"The client tried to work with an unknown virtual host."};
N.ACCESS_REFUSED={value:403,message:"The client attempted to work with a server entity to which it has no access due to security settings."};
N.NOT_FOUND={value:404,message:"The client attempted to work with a server entity that does not exist."};
N.RESOURCE_LOCKED={value:405,message:"The client attempted to work with a server entity to which it has no access because another client is working with it."};
N.PRECONDITION_FAILED={value:406,message:"The client requested a method that was not allowed because some precondition failed."};
N.FRAME_ERROR={value:501,message:"The sender sent a malformed frame that the recipient could not decode. This strongly implies a programming error in the sending peer."};
N.SYNTAX_ERROR={value:502,message:"The sender sent a frame that contained illegal values for one or more fields. This strongly implies a programming error in the sending peer."};
N.COMMAND_INVALID={value:503,message:"The client sent an invalid sequence of frames, attempting to perform an operation that was considered invalid by the server. This usually implies a programming error in the client."};
N.CHANNEL_ERROR={value:504,message:"The client attempted to work with a channel that had not been correctly opened. This most likely indicates a fault in the client layer."};
N.UNEXPECTED_FRAME={value:505,message:"The peer sent a frame that was not expected, usually in the context of a content header and body. This strongly indicates a fault in the peer's content processing."};
N.RESOURCE_ERROR={value:506,message:"The server could not complete the method because it lacked sufficient resources. This may be due to the client creating too many of some type of entity."};
N.NOT_ALLOWED={value:530,message:"The client tried to work with some entity in a manner that is prohibited by the server, due to security settings or by some other criteria."};
N.NOT_IMPLEMENTED={value:540,message:"The client tried to use functionality that is not implemented in the server."};
N.INTERNAL_ERROR={value:541,message:"The server could not complete the method because of an internal error. The server may require intervention by an operator in order to resume normal operations."};
var g={ClassId:{type:"short",asserts:[]},ConsumerTag:{type:"shortstr",asserts:[]},DeliveryTag:{type:"longlong",asserts:[]},ExchangeName:{type:"shortstr",asserts:[]},MethodId:{type:"short",asserts:[]},NoAck:{type:"bit",asserts:[]},NoLocal:{type:"bit",asserts:[]},NoWait:{type:"bit",asserts:[]},Path:{type:"shortstr",asserts:[]},PeerProperties:{type:"table",asserts:[]},QueueName:{type:"shortstr",asserts:[]},Redelivered:{type:"bit",asserts:[]},MessageCount:{type:"long",asserts:[]},ReplyCode:{type:"short",asserts:[]},ReplyText:{type:"shortstr",asserts:[]},Bit:{type:"bit",asserts:[]},Octet:{type:"octet",asserts:[]},Short:{type:"short",asserts:[]},Long:{type:"long",asserts:[]},Longlong:{type:"longlong",asserts:[]},Shortstr:{type:"shortstr",asserts:[]},Longstr:{type:"longstr",asserts:[]},Timestamp:{type:"timestamp",asserts:[]},Table:{type:"table",asserts:[]}};
var V={};
V.Connection={};
V.Connection.startConnection={};
V.Connection.startConnection.allParameters=[{name:"versionMajor",type:"Octet"},{name:"versionMinor",type:"Octet"},{name:"serverProperties",type:"PeerProperties"},{name:"mechanisms",type:"Longstr"},{name:"locales",type:"Longstr"}];
V.Connection.startConnection.returnType="StartOkConnection";
V.Connection.startConnection.index=10;
V.Connection.startConnection.classIndex=10;
V.Connection.startConnection.synchronous=true;
V.Connection.startConnection.hasContent=false;
V.Connection.startOkConnection={};
V.Connection.startOkConnection.allParameters=[{name:"clientProperties",type:"PeerProperties"},{name:"mechanism",type:"Shortstr"},{name:"response",type:"Longstr"},{name:"locale",type:"Shortstr"}];
V.Connection.startOkConnection.returnType="voidConnection";
V.Connection.startOkConnection.index=11;
V.Connection.startOkConnection.classIndex=10;
V.Connection.startOkConnection.synchronous=true;
V.Connection.startOkConnection.hasContent=false;
V.Connection.secureConnection={};
V.Connection.secureConnection.allParameters=[{name:"challenge",type:"Longstr"}];
V.Connection.secureConnection.returnType="SecureOkConnection";
V.Connection.secureConnection.index=20;
V.Connection.secureConnection.classIndex=10;
V.Connection.secureConnection.synchronous=true;
V.Connection.secureConnection.hasContent=false;
V.Connection.secureOkConnection={};
V.Connection.secureOkConnection.allParameters=[{name:"response",type:"Longstr"}];
V.Connection.secureOkConnection.returnType="voidConnection";
V.Connection.secureOkConnection.index=21;
V.Connection.secureOkConnection.classIndex=10;
V.Connection.secureOkConnection.synchronous=true;
V.Connection.secureOkConnection.hasContent=false;
V.Connection.tuneConnection={};
V.Connection.tuneConnection.allParameters=[{name:"channelMax",type:"Short"},{name:"frameMax",type:"Long"},{name:"heartbeat",type:"Short"}];
V.Connection.tuneConnection.returnType="TuneOkConnection";
V.Connection.tuneConnection.index=30;
V.Connection.tuneConnection.classIndex=10;
V.Connection.tuneConnection.synchronous=true;
V.Connection.tuneConnection.hasContent=false;
V.Connection.tuneOkConnection={};
V.Connection.tuneOkConnection.allParameters=[{name:"channelMax",type:"Short"},{name:"frameMax",type:"Long"},{name:"heartbeat",type:"Short"}];
V.Connection.tuneOkConnection.returnType="voidConnection";
V.Connection.tuneOkConnection.index=31;
V.Connection.tuneOkConnection.classIndex=10;
V.Connection.tuneOkConnection.synchronous=true;
V.Connection.tuneOkConnection.hasContent=false;
V.Connection.openConnection={};
V.Connection.openConnection.allParameters=[{name:"virtualHost",type:"Path"},{name:"reserved1",type:"Shortstr"},{name:"reserved2",type:"Bit"}];
V.Connection.openConnection.returnType="OpenOkConnection";
V.Connection.openConnection.index=40;
V.Connection.openConnection.classIndex=10;
V.Connection.openConnection.synchronous=true;
V.Connection.openConnection.hasContent=false;
V.Connection.openOkConnection={};
V.Connection.openOkConnection.allParameters=[{name:"reserved1",type:"Shortstr"}];
V.Connection.openOkConnection.returnType="voidConnection";
V.Connection.openOkConnection.index=41;
V.Connection.openOkConnection.classIndex=10;
V.Connection.openOkConnection.synchronous=true;
V.Connection.openOkConnection.hasContent=false;
V.Connection.closeConnection={};
V.Connection.closeConnection.allParameters=[{name:"replyCode",type:"ReplyCode"},{name:"replyText",type:"ReplyText"},{name:"classId",type:"ClassId"},{name:"methodId",type:"MethodId"}];
V.Connection.closeConnection.returnType="CloseOkConnection";