lightstreamer-jms-node-client
Version:
JavaScript library for the development of Lightstreamer JMS Extender clients running on the Node.js runtime
99 lines (97 loc) • 37.2 kB
JavaScript
/*
LIGHTSTREAMER - www.lightstreamer.com
Lightstreamer JMS Extender Node.js Client
Version 3.0.1 build 151
Copyright (c) Lightstreamer Srl. All Rights Reserved.
Contains: LightstreamerClient, Subscription, SimpleLoggerProvider,
ConsoleAppender, LightstreamerJMS, BytesMessage, CompletionListener,
Connection, ConnectionFactory, ConnectionListener, Destination,
ExceptionListener, JMSConsumer, JMSContext, JMSContextListener,
JMSException, JMSProducer, MapMessage, Message,
MessageConsumer, MessageListener, MessageProducer, ObjectMessage,
Queue, QueueConnection, QueueConnectionFactory, QueueReceiver,
QueueSender, QueueSession, Session, TemporaryQueue,
TemporaryTopic, TextMessage, Topic, TopicConnection,
TopicConnectionFactory, TopicPublisher, TopicSession, TopicSubscriber
CJS
*/
var e=require("lightstreamer-client-node"),IllegalStateException=function(){function a(b){this.name="IllegalStateException";this.message=b}a.prototype={toString:function(){return["[",this.name,this.message,"]"].join("|")}};return a}(),Inheritance=function(){function a(c,d,f){if(d)return f?d.apply(c,f):d.apply(c)}var b={Inheritance:function(c,d,f,k){for(var l in d.prototype)if(!c.prototype[l])c.prototype[l]=d.prototype[l];else if(k){a:{var p=void 0;var g=d.prototype;for(p in g)if(g[l]==g[p]&&l!=p)break a;
p=null}if(p){if(c.prototype[p]&&c.prototype[p]!==c.prototype[l]&&d.prototype[p]!==d.prototype[p])throw new IllegalStateException("Can't solve alias collision, try to minify the classes again ("+p+", "+l+")");c.prototype[p]=c.prototype[l]}}f||(c.prototype._super_=d,c.prototype._callSuperConstructor=b._callSuperConstructor,c.prototype._callSuperMethod=b._callSuperMethod);return c},_callSuperMethod:function(c,d,f){return a(this,c.prototype._super_.prototype[d],f)},_callSuperConstructor:function(c,d){a(this,
c.prototype._super_,d)}};return b.Inheritance}();function h(a,b){this.h=a;this.pa=b;this.I=this.v=this.type=this.priority=this.N=null;this.C={};this.timestamp=this.o=this.i=this.j=this.G=this.body=this.ia=null;this.A=!1}function m(a,b){a.C={};for(var c in b)a.C[c]=b[c]}
h.prototype={J:function(){switch(this.h.i){case "CLIENT_ACK":aa(this.h);break;case "INDIVIDUAL_ACK":this.na();var a=this.h.j.indexOf(this);0<=a&&this.h.j.splice(a,1)}},l:function(){this.body=null},H:function(){this.C={}},R:function(a,b){this.C[a]=b},P:function(a){return this.C[a]},L:function(){return this.G},W:function(a){this.G=a},ea:function(){return this.A},Aa:function(a){this.A=a},wa:function(a){this.N=a},T:function(){return this.N},za:function(a){this.priority=a},ba:function(){return this.priority},
X:function(a){this.type=a},M:function(){return this.type},xa:function(a){this.v=a},$:function(){return this.v},V:function(a){this.I=a},K:function(){return this.I},ta:function(a){this.j=a},U:function(){return this.j},ya:function(a){this.o=a},aa:function(){return this.o},Ba:function(a){this.timestamp=a},Y:function(){return this.timestamp},na:function(){var a={dataAdapterName:this.h.connection.F,localClientId:this.h.connection.clientId,localSessionGuid:this.h.s,destinationType:this.j.fa,destinationName:this.j.O,
subscriptionName:this.i.ka,durable:this.i.oa,noLocal:this.i.qa,shared:this.i.sa,ackMode:this.h.i,messageKind:"ACKNOWLEDGE",messageId:this.o},b=this.h.s.replace(/[^a-zA-Z0-9]+/g,"_");this.h.connection.u.sendMessage(JSON.stringify(a),b,null,null,!0)}};h.prototype.acknowledge=h.prototype.J;h.prototype.clearBody=h.prototype.l;h.prototype.clearProperties=h.prototype.H;h.prototype.getJMSCorrelationID=h.prototype.K;h.prototype.getJMSDeliveryMode=h.prototype.T;h.prototype.getJMSDestination=h.prototype.U;
h.prototype.getJMSExpiration=h.prototype.$;h.prototype.getJMSMessageID=h.prototype.aa;h.prototype.getJMSPriority=h.prototype.ba;h.prototype.getJMSRedelivered=h.prototype.ea;h.prototype.getJMSReplyTo=h.prototype.L;h.prototype.getJMSTimestamp=h.prototype.Y;h.prototype.getJMSType=h.prototype.M;h.prototype.getObjectProperty=h.prototype.P;h.prototype.setJMSCorrelationID=h.prototype.V;h.prototype.setJMSDeliveryMode=h.prototype.wa;h.prototype.setJMSDestination=h.prototype.ta;
h.prototype.setJMSExpiration=h.prototype.xa;h.prototype.setJMSMessageID=h.prototype.ya;h.prototype.setJMSPriority=h.prototype.za;h.prototype.setJMSRedelivered=h.prototype.Aa;h.prototype.setJMSReplyTo=h.prototype.W;h.prototype.setJMSTimestamp=h.prototype.Ba;h.prototype.setJMSType=h.prototype.X;h.prototype.setObjectProperty=h.prototype.R;function n(a,b){this.reason=a;this.g=b}n.prototype={i:function(){return this.reason},h:function(){return this.g}};n.prototype.getErrorCode=n.prototype.h;
n.prototype.getMessage=n.prototype.i;function q(a){this._callSuperConstructor(q,[a,"BYTES_MSG"]);this.body=[];this.g=!1;this.position=0}
q.prototype={l:function(){this.body=[];this.g=!1;this.position=0},S:function(){if(!this.g)throw new n("Message is in write-only mode");return this.body.length},Z:function(){if(!this.g)throw new n("Message is in write-only mode");if(this.position+1>this.body.length)throw new n("Unexpected end of stream");var a=0!=(this.body[this.position]&255)?!0:!1;this.position++;return a},D:function(){if(!this.g)throw new n("Message is in write-only mode");if(this.position+1>this.body.length)throw new n("Unexpected end of stream");
var a=this.body[this.position]&255;this.position++;return a},ua:function(){if(!this.g)throw new n("Message is in write-only mode");if(this.position+2>this.body.length)throw new n("Unexpected end of stream");var a=(this.body[this.position]&255)<<8;a|=this.body[this.position+1]&255;this.position+=2;return a},la:function(){if(!this.g)throw new n("Message is in write-only mode");if(this.position+2>this.body.length)throw new n("Unexpected end of stream");var a=(this.body[this.position]&255)<<8;a|=this.body[this.position+
1]&255;this.position+=2;return String.fromCharCode(a)},ma:function(){if(!this.g)throw new n("Message is in write-only mode");if(this.position+4>this.body.length)throw new n("Unexpected end of stream");var a=(this.body[this.position]&255)<<24;a|=(this.body[this.position+1]&255)<<16;a|=(this.body[this.position+2]&255)<<8;a|=this.body[this.position+3]&255;this.position+=4;return a},va:function(){if(!this.g)throw new n("Message is in write-only mode");var a="";do{var b=this.D();if(0!=b)a+=String.fromCharCode(b);
else break}while(1);return decodeURIComponent(escape(a))},ha:function(a,b){if(!this.g)throw new n("Message is in write-only mode");null==b&&(b=a.length);var c=0;do{if(this.position>=this.body.length)break;a[c]=this.body[this.position];c++;this.position++;if(c>=b)break}while(1);return 0==c?-1:c},reset:function(){this.position=0;this.g=!0},Ca:function(a){if(this.g)throw new n("Message is in read-only mode");this.body.push(a?1:0)},m:function(a){if(this.g)throw new n("Message is in read-only mode");this.body.push(a)},
Fa:function(a){if(this.g)throw new n("Message is in read-only mode");this.body.push((a&65280)>>8);this.body.push(a&255)},Da:function(a){if(this.g)throw new n("Message is in read-only mode");this.body.push((a.charCodeAt(0)&65280)>>8);this.body.push(a.charCodeAt(0)&255)},Ea:function(a){if(this.g)throw new n("Message is in read-only mode");this.body.push((a&4278190080)>>24);this.body.push((a&16711680)>>16);this.body.push((a&65280)>>8);this.body.push(a&255)},Ga:function(a){if(this.g)throw new n("Message is in read-only mode");
for(var b=unescape(encodeURIComponent(a)),c=0;c<b.length;c++)this.m(a.charCodeAt(c));this.m(0)},B:function(a){if(this.g)throw new n("Message is in read-only mode");for(var b=0;b<a.length;b++)this.m(a[b])}};q.prototype.clearBody=q.prototype.l;q.prototype.getBodyLength=q.prototype.S;q.prototype.readBoolean=q.prototype.Z;q.prototype.readByte=q.prototype.D;q.prototype.readBytes=q.prototype.ha;q.prototype.readChar=q.prototype.la;q.prototype.readInt=q.prototype.ma;q.prototype.readShort=q.prototype.ua;
q.prototype.readUTF=q.prototype.va;q.prototype.reset=q.prototype.reset;q.prototype.writeBoolean=q.prototype.Ca;q.prototype.writeByte=q.prototype.m;q.prototype.writeBytes=q.prototype.B;q.prototype.writeChar=q.prototype.Da;q.prototype.writeInt=q.prototype.Ea;q.prototype.writeShort=q.prototype.Fa;q.prototype.writeUTF=q.prototype.Ga;Inheritance(q,h);function ba(){}ba.prototype={ja:function(){}};function r(a){this._callSuperConstructor(r,[a,"TEXT_MSG"])}r.prototype={g:function(a){this.body=a},m:function(){return this.body}};
r.prototype.getText=r.prototype.m;r.prototype.setText=r.prototype.g;Inheritance(r,h);function t(a){this._callSuperConstructor(t,[a,"OBJECT_MSG"])}t.prototype={g:function(a){this.body=a},D:function(){return this.body},m:function(a){this.ia=a},B:function(){return this.ia}};t.prototype.getClassFQN=t.prototype.B;t.prototype.setClassFQN=t.prototype.m;t.prototype.getObject=t.prototype.D;t.prototype.setObject=t.prototype.g;Inheritance(t,h);
function u(a){this._callSuperConstructor(u,[a,"MAP_MSG"]);this.body={}}u.prototype={g:function(a,b){this.body[a]=b},m:function(a){return this.body[a]},l:function(){this.body={}}};u.prototype.getObject=u.prototype.m;u.prototype.setObject=u.prototype.g;u.prototype.clearBody=u.prototype.l;Inheritance(u,h);function fa(a,b){this.fa=a;this.O=b}function v(a){this._callSuperConstructor(v,["TOPIC",a])}v.prototype={i:function(){return this.O}};v.prototype.getTopicName=v.prototype.i;Inheritance(v,fa);
function w(a){this._callSuperConstructor(w,["QUEUE",a])}w.prototype={i:function(){return this.O}};w.prototype.getQueueName=w.prototype.i;Inheritance(w,fa);function x(a,b){this.g=b;this._callSuperConstructor(x,[a])}
x.prototype={h:function(){var a={dataAdapterName:this.g.connection.F,localClientId:this.g.connection.clientId,localSessionGuid:this.g.s,destinationType:"QUEUE",destinationName:this.O,messageKind:"DELETE_TEMP_TOPIC"},b=this.g.s.replace(/[^a-zA-Z0-9]+/g,"_");this.g.connection.u.sendMessage(JSON.stringify(a),b,null,null,!0)}};x.prototype.deleteTemporaryTopic=x.prototype.h;Inheritance(x,v);function y(a,b){this.g=b;this._callSuperConstructor(y,[a])}
y.prototype={h:function(){var a={dataAdapterName:this.g.connection.F,localClientId:this.g.connection.clientId,localSessionGuid:this.g.s,destinationType:"QUEUE",destinationName:this.O,messageKind:"DELETE_TEMP_QUEUE"},b=this.g.s.replace(/[^a-zA-Z0-9]+/g,"_");this.g.connection.u.sendMessage(JSON.stringify(a),b,null,null,!0)}};y.prototype.deleteTemporaryQueue=y.prototype.h;Inheritance(y,w);
function ha(a){var b=[];if(!a)return"";var c=0;do{var d=a[c++];var f=a[c++];var k=a[c++];var l=d<<16|f<<8|k;d=l>>18&63;f=l>>12&63;k=l>>6&63;l&=63;b.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(d)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(f)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(k)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(l))}while(c<a.length);b=b.join("");a=a.length%
3;return(a?b.slice(0,a-3):b)+"===".slice(a||3)}function B(a,b,c,d,f){this.g=a;this.o=b;this.N=c;this.l=0;this.priority=d;this.h=f;this.i=!0}
B.prototype={H:function(){return this.o},m:function(a){this.N=a},D:function(){return this.N},v:function(a){this.priority=a},B:function(){return this.priority},A:function(a){this.h=a},J:function(){return this.h},j:function(a,b,c){if(!this.i)throw new IllegalStateException("Producer has been closed");null==b&&(b=this.o);if(null==b)throw new IllegalStateException("This producer has no defined destination");this.sendMessage(a,b,c)},close:function(){if(this.i){this.i=!1;var a=this.g.o.indexOf(this);0<=
a&&this.g.o.splice(a,1)}},sendMessage:function(a,b,c){try{var d={dataAdapterName:this.g.connection.F,localClientId:this.g.connection.clientId,localSessionGuid:this.g.s,destinationType:b.fa,destinationName:b.O,ackMode:this.g.i,messageKind:a.pa,deliveryMode:a.N,deliveryDelay:this.l,priority:a.priority,messageProperties:a.C};switch(a.pa){case "TEXT_MSG":case "OBJECT_MSG":case "MAP_MSG":"OBJECT_MSG"==a.pa&&(d.classFQN=a.ia);d.payload=a.body;break;case "BYTES_MSG":d.payload=ha(a.body)}null!=a.G&&(d.replyDestinationType=
a.G.fa,d.replyDestinationName=a.G.O);null==d.deliveryMode&&(d.deliveryMode=this.N);null==d.priority&&(d.priority=this.priority);null==d.timeToLive&&(d.timeToLive=this.h);null!=a.type&&(d.type=a.type);null!=a.I&&(d.correlationId=a.I);var f=this.g.s.replace(/[^a-zA-Z0-9]+/g,"_");b=null;null!=c&&(b={onAbort:function(){c.onException(a,new n("Message sending has been aborted"))},onDeny:function(k,l,p){c.onException(a,new n("The message has been denied by the server: "+p,l))},onDiscarded:function(){c.onException(a,
new n("The message has been discarded by the server"))},onError:function(){c.onException(a,new n("A server internal error occurred while sending the message"))},onProcessed:function(){c.onCompletion(a)}});this.g.connection.u.sendMessage(JSON.stringify(d),f,null,b,!0)}catch(k){try{console.log("MessageProducer: exception while sending message: "+k)}catch(l){}}}};B.prototype.close=B.prototype.close;B.prototype.getDeliveryMode=B.prototype.D;B.prototype.getDestination=B.prototype.H;
B.prototype.getPriority=B.prototype.B;B.prototype.getTimeToLive=B.prototype.J;B.prototype.send=B.prototype.j;B.prototype.setDeliveryMode=B.prototype.m;B.prototype.setPriority=B.prototype.v;B.prototype.setTimeToLive=B.prototype.A;
function C(a,b,c,d,f,k,l){this.g=a;this.l=b;this.ka=c;this.oa=d;this.qa=f;this.sa=k;this.o=l;this.i=null;this.ga=[];this.j=!0;this.m={dataAdapterName:this.g.connection.F,localClientId:this.g.connection.clientId,localSessionGuid:this.g.s,destinationType:this.l.fa,destinationName:this.l.O,subscriptionName:this.ka,durable:this.oa,noLocal:this.qa,shared:this.sa,ackMode:this.g.i};null!=this.o&&(this.m.selector=encodeURIComponent(this.o));this.h=new e.Subscription("RAW",JSON.stringify(this.m),"dataAdapterName destinationType destinationName replyDestinationType replyDestinationName messageRedelivered messageId messageKind type priority expiration deliveryMode correlationId messageProperties classFQN payload timestamp deliveryTime".split(" "));
this.h.setDataAdapter(this.g.connection.F);this.h.setRequestedSnapshot("no");var p=this;this.h.addListener({onItemUpdate:function(g){try{var z=g.getValue("replyDestinationType"),E=g.getValue("replyDestinationName"),L=g.getValue("messageId"),M=g.getValue("messageKind"),T="true"==g.getValue("messageRedelivered"),Q=g.getValue("messageProperties"),A=g.getValue("classFQN"),F=g.getValue("payload"),wa=g.getValue("timestamp"),xa=g.getValue("type"),ya=g.getValue("expiration"),za=g.getValue("priority"),Aa=
g.getValue("correlationId"),Ba=g.getValue("deliveryMode");g.getValue("deliveryTime");g=null;switch(M){case "TEXT_MSG":g=new r(p.g);g.body=F;break;case "OBJECT_MSG":g=new t(p.g);g.body=JSON.parse(F);g.ia=A;break;case "MAP_MSG":g=new u(p.g);g.body=JSON.parse(F);break;case "BYTES_MSG":M=g=new q(p.g);A=[];if(F){var U=0;do{var Ca="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(U++));var Da="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(U++));
var la="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(U++));var ma="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(U++));var ca=Ca<<18|Da<<12|la<<6|ma;var da=ca>>16&255;var na=ca>>8&255;var Ea=ca&255;64==la?A.push(da):64==ma?(A.push(da),A.push(na)):(A.push(da),A.push(na),A.push(Ea))}while(U<F.length);var oa=A}else oa=[];M.body=oa;g.g=!0}if(null!=g)if(g.o=L,g.C=0<Q.length?JSON.parse(Q):{},g.j=p.l,g.i=p,g.timestamp=wa,g.A=T,
g.N=Ba,g.priority=za,g.type=xa,g.v=ya,g.I=Aa,null!=z&&("TOPIC"==z?g.G=new v(E):"QUEUE"==z&&(g.G=new w(E))),null!=p.i){try{p.i.onMessage(g)}catch(ea){try{console.log("MessageConsumer: exception while forwarding message to the listener: "+ea)}catch(Fa){}}ia(p,g)}else p.ga.push(g)}catch(ea){try{console.log("MessageConsumer: exception while processing message: "+ea)}catch(Fa){}}}})}
function ia(a,b){switch(a.g.i){case "AUTO_ACK":D(a);break;case "CLIENT_ACK":a.g.j.push(b);D(a);break;case "TRANSACTED":D(a);break;case "DUPS_OK":a.g.j.push(b);null==a.g.J&&(a.g.J=setTimeout(function(){aa(a.g)},150));break;case "INDIVIDUAL_ACK":a.g.j.push(b)}}
function D(a){if(a.j)switch(a.g.i){case "AUTO_ACK":case "CLIENT_ACK":case "TRANSACTED":var b={dataAdapterName:a.g.connection.F,localClientId:a.g.connection.clientId,localSessionGuid:a.g.s,destinationType:a.l.fa,destinationName:a.l.O,subscriptionName:a.ka,durable:a.oa,noLocal:a.qa,shared:a.sa,ackMode:a.g.i,messageKind:"READ_NEXT"},c=a.g.s.replace(/[^a-zA-Z0-9]+/g,"_");a.g.connection.u.sendMessage(JSON.stringify(b),c,null,null,!0)}}
C.prototype={B:function(){return this.o},D:function(){return this.i},A:function(a){if(!this.j)throw new IllegalStateException("Consumer has been closed");this.i=a;this.g.h&&D(this)},v:function(){if(!this.j)throw new IllegalStateException("Consumer has been closed");if(0<this.ga.length){var a=this.ga.splice(0,1)[0];ia(this,a);return a}this.g.h&&D(this)},close:function(){if(this.j){this.j=!1;this.i=null;this.h.isSubscribed()&&this.g.connection.u.unsubscribe(this.h);this.h=null;var a=this.g.g.indexOf(this);
0<=a&&this.g.g.splice(a,1)}},start:function(){if(!this.j)throw new IllegalStateException("Consumer has been closed");this.h.isSubscribed()||this.g.connection.u.subscribe(this.h);null!=this.i&&D(this)},stop:function(){if(!this.j)throw new IllegalStateException("Consumer has been closed");this.h.isSubscribed()&&this.g.connection.u.unsubscribe(this.h)}};C.prototype.close=C.prototype.close;C.prototype.getMessageListener=C.prototype.D;C.prototype.getMessageSelector=C.prototype.B;
C.prototype.receiveNoWait=C.prototype.v;C.prototype.setMessageListener=C.prototype.A;function G(a,b,c,d,f,k,l,p){this._callSuperConstructor(G,[a,b,c,d,f,k,l]);this.i=p}Inheritance(G,C);function H(a,b,c){this.connection=a;this.i=(this.m=b)?"TRANSACTED":c;this.s="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(d){var f=16*Math.random()|0;return("x"==d?f:f&3|8).toString(16)});this.J=null;this.j=[];this.l=!0;this.h=!1;this.o=[];this.g=[]}
function aa(a){a.J=null;if(0<a.j.length){var b=[];switch(a.ha){case "DUPS_OK":case "CLIENT_ACK":var c=a.j.pop();b.add(c);break;case "INDIVIDUAL_ACK":b=a.j}a.j=[];for(c in b)try{c.na()}catch(d){try{console.log("Session: exception while acknowledging message: "+d)}catch(f){}}}}
H.prototype={ea:function(){return this.m},ba:function(){return this.i},K:function(a,b,c){a=new C(this,a,null,!1,null!=c?c:!1,!1,b,null);this.g.push(a);this.h&&a.start();return a},M:function(a){a=new B(this,a,"PERSISTENT",4,0);this.o.push(a);return a},aa:function(a,b,c,d){if(null==this.connection.clientId)throw new n("Connection client ID not set");a=new G(this,a,b,!0,null!=d?d:!1,!1,c,null);this.g.push(a);return a},unsubscribe:function(a){var b=this.s.replace(/[^a-zA-Z0-9]+/g,"_");this.connection.u.sendMessage(JSON.stringify({dataAdapterName:this.connection.F,
localClientId:this.connection.clientId,localSessionGuid:this.s,destinationType:"TOPIC",subscriptionName:a,messageKind:"UNSUBSCRIBE"}),b,null,null,!0)},T:function(a){return new v(a)},P:function(a){return new w(a)},L:function(){if(!this.l)throw new IllegalStateException("Session has been closed");return new h(this,"TEXT_MSG")},B:function(a){if(!this.l)throw new IllegalStateException("Session has been closed");var b=new r(this);b.g(a);return b},D:function(a,b){if(!this.l)throw new IllegalStateException("Session has been closed");
var c=new t(this);c.g(a);c.m(b);return c},A:function(){if(!this.l)throw new IllegalStateException("Session has been closed");return new u(this)},v:function(){if(!this.l)throw new IllegalStateException("Session has been closed");return new q(this)},R:function(a,b){var c="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(k){var l=16*Math.random()|0;return("x"==k?l:l&3|8).toString(16)}),d=this;ja(this.connection,c,{ca:function(k){k=new y(k,d);try{a(k)}catch(l){try{console.log("Session: exception while calling temp queue callback: "+
l)}catch(p){}}},ja:function(k,l,p){var g=null;switch(k){case "GENERIC_EXCEPTION":g=new n(l,p)}try{"function"==typeof b?b(g):console.log("Session: provided onTempQueueFailed is not a valid callback")}catch(z){try{console.log("Session: exception while calling temp queue exception callback: "+z)}catch(E){}}}});var f=this.s.replace(/[^a-zA-Z0-9]+/g,"_");this.connection.u.sendMessage(JSON.stringify({dataAdapterName:this.connection.F,localClientId:this.connection.clientId,localSessionGuid:this.s,destinationType:"QUEUE",
ackMode:this.i,operationId:c,messageKind:"CREATE_TEMP_QUEUE"}),f,null,null,!0)},S:function(a,b){var c="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(k){var l=16*Math.random()|0;return("x"==k?l:l&3|8).toString(16)}),d=this;ja(this.connection,c,{ca:function(k){k=new x(k,d);try{a(k)}catch(l){try{console.log("Session: exception while calling temp topic callback: "+l)}catch(p){}}},ja:function(k,l,p){var g=null;switch(k){case "GENERIC_EXCEPTION":g=new n(l,p)}try{"function"==typeof b?b(g):
console.log("Session: provided onTempTopicFailed is not a valid callback")}catch(z){try{console.log("Session: exception while calling temp topic exception callback: "+z)}catch(E){}}}});var f=this.s.replace(/[^a-zA-Z0-9]+/g,"_");this.connection.u.sendMessage(JSON.stringify({dataAdapterName:this.connection.F,localClientId:this.connection.clientId,localSessionGuid:this.s,destinationType:"QUEUE",ackMode:this.i,operationId:c,messageKind:"CREATE_TEMP_TOPIC"}),f,null,null,!0)},H:function(){if(!this.m)throw new IllegalStateException("Session is not transacted");
var a=this.s.replace(/[^a-zA-Z0-9]+/g,"_");this.connection.u.sendMessage(JSON.stringify({dataAdapterName:this.connection.F,localClientId:this.connection.clientId,localSessionGuid:this.s,destinationType:"QUEUE",messageKind:"COMMIT"}),a,null,null,!0)},$:function(){if(!this.m)throw new IllegalStateException("Session is not transacted");for(var a=0;a<this.g.length;a++)this.g[a].ga=[];a=this.s.replace(/[^a-zA-Z0-9]+/g,"_");this.connection.u.sendMessage(JSON.stringify({dataAdapterName:this.connection.F,
localClientId:this.connection.clientId,localSessionGuid:this.s,destinationType:"QUEUE",messageKind:"ROLLBACK"}),a,null,null,!0)},U:function(){if(this.m)throw new IllegalStateException("Session is transacted");for(var a=0;a<this.g.length;a++)this.g[a].ga=[];a=this.s.replace(/[^a-zA-Z0-9]+/g,"_");this.connection.u.sendMessage(JSON.stringify({dataAdapterName:this.connection.F,localClientId:this.connection.clientId,localSessionGuid:this.s,destinationType:"QUEUE",messageKind:"RECOVER"}),a,null,null,!0)},
close:function(){if(this.l){for(this.h=this.l=!1;0<this.o.length;)this.o.shift().close();for(;0<this.g.length;)this.g.shift().close();var a=this.connection.g.indexOf(this);0<=a&&this.connection.g.splice(a,1)}},start:function(){if(!this.h){this.h=!0;for(var a=0;a<this.g.length;a++)this.g[a].start()}},stop:function(){if(this.h){this.h=!1;for(var a=0;a<this.g.length;a++)this.g[a].stop()}}};H.prototype.close=H.prototype.close;H.prototype.commit=H.prototype.H;H.prototype.createBytesMessage=H.prototype.v;
H.prototype.createConsumer=H.prototype.K;H.prototype.createDurableSubscriber=H.prototype.aa;H.prototype.createMapMessage=H.prototype.A;H.prototype.createMessage=H.prototype.L;H.prototype.createObjectMessage=H.prototype.D;H.prototype.createProducer=H.prototype.M;H.prototype.createQueue=H.prototype.P;H.prototype.createTemporaryQueue=H.prototype.R;H.prototype.createTemporaryTopic=H.prototype.S;H.prototype.createTextMessage=H.prototype.B;H.prototype.createTopic=H.prototype.T;
H.prototype.getAcknowledgeMode=H.prototype.ba;H.prototype.getTransacted=H.prototype.ea;H.prototype.recover=H.prototype.U;H.prototype.rollback=H.prototype.$;H.prototype.unsubscribe=H.prototype.unsubscribe;var IllegalArgumentException=function(){function a(b){this.name="IllegalArgumentException";this.message=b}a.prototype={toString:function(){return["[",this.name,this.message,"]"].join("|")}};return a}();
function I(a,b,c){this.u=a;this.F=b;this.M=null!=c?c:!1;this.j=this.clientId=null;this.i=!1;this.v=!0;this.h=!1;this.g=[];this.m={};this.K={dataAdapterName:this.F,localClientId:null,localSessionGuid:"-",destinationType:"EXCEPTIONS"};this.l=new e.Subscription("RAW",JSON.stringify(this.K),["dataAdapterName","localSessionGuid","exceptionType","exceptionReason","exceptionErrorCode"]);this.l.setDataAdapter(this.F);this.l.setRequestedSnapshot("no");var d=this;this.l.addListener({onItemUpdate:function(f){if(null!=
d.j)try{var k=f.getValue("localSessionGuid");if(null!=k){for(var l=!1,p=0;p<d.g.length;p++)if(d.g[p].s==k){l=!0;break}if(!l)return}var g=f.getValue("exceptionType"),z=f.getValue("exceptionReason"),E=f.getValue("exceptionErrorCode");f=null;switch(g){case "GENERIC_EXCEPTION":f=new n(z,E)}if(null!=f)try{d.j.onException(f)}catch(L){try{console.log("Connection: exception while forwarding asynchronous exception: "+L)}catch(M){}}}catch(L){try{console.log("Connection: exception while processing asynchronous exception: "+
L)}catch(M){}}}});this.u.subscribe(this.l);this.L={dataAdapterName:this.F,localClientId:null,localSessionGuid:"-",destinationType:"OUTCOMES"};this.o=new e.Subscription("RAW",JSON.stringify(this.L),"dataAdapterName localSessionGuid operationId operationOutcome exceptionType exceptionReason exceptionErrorCode".split(" "));this.o.setDataAdapter(this.F);this.o.setRequestedSnapshot("no");this.o.addListener({onItemUpdate:function(f){try{var k=f.getValue("localSessionGuid");if(null!=k){for(var l=!1,p=0;p<
d.g.length;p++)if(d.g[p].s==k){l=!0;break}if(!l)return}var g=f.getValue("operationId"),z=f.getValue("operationOutcome"),E=f.getValue("exceptionType"),L=f.getValue("exceptionReason"),M=f.getValue("exceptionErrorCode"),T=d.m[g];if(null!=T){d.m[g]=null;try{null!=E?T.ja(E,L,M):T.ca(z)}catch(Q){try{console.log("Connection: exception while forwarding operation outcome: "+Q)}catch(A){}}}}catch(Q){try{console.log("Connection: exception while processing operation outcome: "+Q)}catch(A){}}}});this.u.subscribe(this.o)}
function ja(a,b,c){a.m[b]=c}
I.prototype={D:function(){return this.clientId},J:function(a){if(this.i)throw new IllegalStateException("Connection has already been used");this.clientId=a},B:function(){return this.j},A:function(a){this.j=a},createSession:function(a,b){this.i=!0;if(null==a&&null==b)a=new H(this,!1,"AUTO_ACK");else if("boolean"==typeof a)a=new H(this,a,b);else if("string"==typeof a)a=new H(this,"TRANSACTED"==a,a);else throw new IllegalArgumentException("Invalid arguments");this.g.push(a);this.h&&a.start();return a},
start:function(){this.i=!0;if(!this.h){this.h=!0;for(var a=0;a<this.g.length;a++)this.g[a].start()}},stop:function(){this.i=!0;if(this.h){this.h=!1;for(var a=0;a<this.g.length;a++)this.g[a].stop()}},close:function(){this.i=!0;if(this.v){this.h=this.v=!1;for(this.j=null;0<this.g.length;)this.g.shift().close();this.M&&this.u.disconnect()}}};I.prototype.close=I.prototype.close;I.prototype.createSession=I.prototype.createSession;I.prototype.getClientID=I.prototype.D;I.prototype.getExceptionListener=I.prototype.B;
I.prototype.setClientID=I.prototype.J;I.prototype.setExceptionListener=I.prototype.A;I.prototype.start=I.prototype.start;I.prototype.stop=I.prototype.stop;function J(a,b,c,d,f,k){b=new e.LightstreamerClient(b,"JMS");b.connectionDetails.setUser(d);b.connectionDetails.setPassword(f);a=new a(b,c,!0);k=new K(k,a,b);b.addListener(k);k.start(b);b.connect()}function K(a,b,c){this.da=a;this.connection=b;this.u=c}
K.prototype={ca:function(a,b){if(this.da&&this.da[a])try{b?this.da[a].apply(this.da,b):this.da[a].apply(this.da)}catch(c){console.log("ConnectionFactory: exception while calling the "+a+" callback: "+c)}},start:function(){this.ca("onLSClient",[this.u])},onServerError:function(a,b){this.ca("onConnectionFailed",[a,b]);this.u.disconnect()},onStatusChange:function(a){switch(a){case "CONNECTED:WS-STREAMING":case "CONNECTED:HTTP-STREAMING":case "CONNECTED:WS-POLLING":case "CONNECTED:HTTP-POLLING":this.ca("onConnectionCreated",
[this.connection]),this.u.removeListener(this)}}};K.prototype.onStatusChange=K.prototype.onStatusChange;K.prototype.onServerError=K.prototype.onServerError;function ka(){}ka.prototype={};function N(a){this.g=a}N.prototype={i:function(){return this.g.o},h:function(){return this.g.i},l:function(a){this.g.A(a)},j:function(){return this.g.v()},close:function(){this.g.close()}};N.prototype.getMessageSelector=N.prototype.i;N.prototype.getMessageListener=N.prototype.h;N.prototype.setMessageListener=N.prototype.l;
N.prototype.receiveNoWait=N.prototype.j;N.prototype.close=N.prototype.close;function O(a){this.h=a;this.C={};this.g=a.M(null);this.i=this.G=this.I=this.type=null}
O.prototype={H:function(a,b,c){if("object"==typeof b&&void 0!=b.na){b=c=b;var d=this.C,f;for(f in d)b.C[f]=d[f];null!=this.type&&c.X(this.type);null!=this.I&&c.V(this.I);null!=this.G&&c.W(this.G)}else if("string"==typeof b)c=this.h.B(b),m(c,this.C),c.X(this.type),c.V(this.I),c.W(this.G);else if("object"==typeof b&&null==c){c=this.h.A();for(d in b)c.g(d,b.Ha);m(c,this.C);c.X(this.type);c.V(this.I);c.W(this.G)}else"object"==typeof b&&null!=c?(c=this.h.D(b,c),m(c,this.C),c.X(this.type),c.V(this.I),c.W(this.G)):
(c=this.h.v(),null!=b&&c.B(b),m(c,this.C),c.X(this.type),c.V(this.I),c.W(this.G));this.g.j(c,a,this.i);return this},L:function(a){this.g.m(a);return this},o:function(){return this.g.N},P:function(a){this.g.v(a);return this},B:function(){return this.g.priority},R:function(a){this.g.A(a);return this},J:function(){return this.g.h},K:function(a){this.g.l=a;return this},l:function(){return this.g.l},U:function(a){this.i=a;return this},S:function(){return this.i},M:function(a,b){this.C[a]=b;return this},
j:function(){this.C={};return this},T:function(a){return null!=this.C[a]},D:function(a){return this.C[a]},V:function(a){this.I=a;return this},m:function(){return this.I},X:function(a){this.type=a;return this},A:function(){return this.type},W:function(a){this.G=a;return this},v:function(){return this.G}};O.prototype.send=O.prototype.H;O.prototype.setDeliveryMode=O.prototype.L;O.prototype.getDeliveryMode=O.prototype.o;O.prototype.setPriority=O.prototype.P;O.prototype.getPriority=O.prototype.B;
O.prototype.setTimeToLive=O.prototype.R;O.prototype.getTimeToLive=O.prototype.J;O.prototype.setDeliveryDelay=O.prototype.K;O.prototype.getDeliveryDelay=O.prototype.l;O.prototype.setAsync=O.prototype.U;O.prototype.getAsync=O.prototype.S;O.prototype.setObjectProperty=O.prototype.M;O.prototype.clearProperties=O.prototype.j;O.prototype.propertyExists=O.prototype.T;O.prototype.getObjectProperty=O.prototype.D;O.prototype.setJMSCorrelationID=O.prototype.V;O.prototype.getJMSCorrelationID=O.prototype.m;
O.prototype.setJMSType=O.prototype.X;O.prototype.getJMSType=O.prototype.A;O.prototype.setJMSReplyTo=O.prototype.W;O.prototype.getJMSReplyTo=O.prototype.v;function P(a,b){this.connection=a;this.h=b;this.g=!1;this.i=!0}
P.prototype={Z:function(a){a=this.connection.createSession(a);return new P(this.connection,a)},J:function(){return new O(this.h)},T:function(){return this.connection.clientId},ea:function(a){if(this.g)throw new IllegalStateException("The context has already been used");this.connection.clientId=a},U:function(){return this.connection.j},Y:function(a){this.connection.A(a)},start:function(){this.g=!0;this.connection.start()},stop:function(){this.g=!0;this.connection.stop()},ma:function(a){this.i=a},ha:function(){return this.i},
close:function(){this.g=!0;this.connection.close()},o:function(){this.g=!0;return this.h.v()},A:function(){this.g=!0;return this.h.A()},D:function(){this.g=!0;return this.h.L()},B:function(a){this.g=!0;return this.h.D(a)},R:function(a){this.g=!0;return this.h.B(a)},$:function(){return this.h.m},la:function(){return this.h.ba()},l:function(){this.g=!0;this.h.H()},ba:function(){this.g=!0;this.h.$()},aa:function(){this.g=!0;this.h.U()},m:function(a,b,c){this.g=!0;a=this.h.K(a,b,c);this.i&&this.start();
return new N(a)},H:function(a){this.g=!0;return this.h.P(a)},S:function(a){this.g=!0;return this.h.T(a)},v:function(a,b,c,d){this.g=!0;a=this.h.aa(a,b,c,d);this.i&&this.start();return new N(a)},L:function(a,b,c){this.g=!0;var d=this.h;if(null==d.connection.clientId)throw new n("Connection client ID not set");a=new C(d,a,b,!0,!1,!0,c,null);d.g.push(a);d.h&&a.start();this.i&&this.start();return new N(a)},K:function(a,b,c){this.g=!0;var d=this.h;if(null==d.connection.clientId)throw new n("Connection client ID not set");
a=new C(d,a,b,!1,!1,!0,c,null);d.g.push(a);d.h&&a.start();this.i&&this.start();return new N(a)},M:function(a,b){this.g=!0;return this.h.R(a,b)},P:function(a,b){this.g=!0;return this.h.S(a,b)},unsubscribe:function(a){this.g=!0;this.h.unsubscribe(a)},j:function(){this.g=!0;aa(this.h)}};P.prototype.createContext=P.prototype.Z;P.prototype.createProducer=P.prototype.J;P.prototype.getClientID=P.prototype.T;P.prototype.setClientID=P.prototype.ea;P.prototype.getExceptionListener=P.prototype.U;
P.prototype.setExceptionListener=P.prototype.Y;P.prototype.start=P.prototype.start;P.prototype.stop=P.prototype.stop;P.prototype.setAutoStart=P.prototype.ma;P.prototype.getAutoStart=P.prototype.ha;P.prototype.close=P.prototype.close;P.prototype.createBytesMessage=P.prototype.o;P.prototype.createMapMessage=P.prototype.A;P.prototype.createMessage=P.prototype.D;P.prototype.createObjectMessage=P.prototype.B;P.prototype.createTextMessage=P.prototype.R;P.prototype.getTransacted=P.prototype.$;
P.prototype.getSessionMode=P.prototype.la;P.prototype.commit=P.prototype.l;P.prototype.rollback=P.prototype.ba;P.prototype.recover=P.prototype.aa;P.prototype.createConsumer=P.prototype.m;P.prototype.createQueue=P.prototype.H;P.prototype.createTopic=P.prototype.S;P.prototype.createDurableConsumer=P.prototype.v;P.prototype.createSharedDurableConsumer=P.prototype.L;P.prototype.createSharedConsumer=P.prototype.K;P.prototype.createTemporaryQueue=P.prototype.M;P.prototype.createTemporaryTopic=P.prototype.P;
P.prototype.unsubscribe=P.prototype.unsubscribe;P.prototype.acknowledge=P.prototype.j;function pa(){}function qa(a,b,c,d,f,k){return J(I,a,b,c,d,{onLSClient:function(l){null!=k.ra&&k.ra(l)},onConnectionCreated:function(l){var p=l.createSession(f);l=new P(l,p);if(null!=k.onContextCreated)k.onContextCreated(l)},onConnectionFailed:function(l,p){if(null!=k.onContextCreated)k.onContextCreated(l,p)}})}pa.createConnection=function(a,b,c,d,f){return J(I,a,b,c,d,f)};pa.createContext=qa;function ra(){}
ra.prototype={ra:function(){},g:function(){},h:function(){}};function sa(){}sa.prototype={ja:function(){}};function ta(){}ta.prototype={ra:function(){}};function R(a,b,c,d){this._callSuperConstructor(R,[a,b,null,!1,!1,!1,c]);this.i=d}Inheritance(R,C);function S(a,b,c,d,f){this._callSuperConstructor(S,[a,b,c,d,f])}Inheritance(S,B);function V(a,b,c){this._callSuperConstructor(V,[a,b,c])}
V.prototype={Y:function(a,b){a=new R(this,a,b,null);this.g.push(a);this.h&&a.start();return a},Z:function(a){a=new S(this,a,"PERSISTENT",4,0);this.o.push(a);return a}};V.prototype.createReceiver=V.prototype.Y;V.prototype.createSender=V.prototype.Z;Inheritance(V,H);function W(a,b,c){this._callSuperConstructor(W,[a,b,c])}W.prototype={H:function(a,b){this.i=!0;a=new V(this,a,b);this.g.push(a);this.h&&a.start();return a}};W.prototype.createQueueSession=W.prototype.H;Inheritance(W,I);function ua(){}
ua.createQueueConnection=function(a,b,c,d,f){return J(W,a,b,c,d,f)};ua.createContext=function(a,b,c,d,f,k){return qa(a,b,c,d,f,k)};function X(a,b,c,d,f){this._callSuperConstructor(X,[a,b,c,d,f])}X.prototype={K:function(a){this.j(a)}};X.prototype.publish=X.prototype.K;Inheritance(X,B);function Y(a,b,c){this._callSuperConstructor(Y,[a,b,c])}
Y.prototype={Z:function(a,b){a=new G(this,a,null,b,null);this.g.push(a);this.h&&a.start();return a},Y:function(a){a=new X(this,a,"PERSISTENT",4,0);this.o.push(a);return a}};Y.prototype.createPublisher=Y.prototype.Y;Y.prototype.createSubscriber=Y.prototype.Z;Inheritance(Y,H);function Z(a,b,c){this._callSuperConstructor(Z,[a,b,c])}Z.prototype={H:function(a,b){this.i=!0;a=new Y(this,a,b);this.g.push(a);this.h&&a.start();return a}};Z.prototype.createTopicSession=Z.prototype.H;Inheritance(Z,I);
function va(){}va.createTopicConnection=function(a,b,c,d,f){return J(Z,a,b,c,d,f)};va.createContext=function(a,b,c,d,f,k){return qa(a,b,c,d,f,k)};
module.exports={LightstreamerClient:e.LightstreamerClient,Subscription:e.Subscription,SimpleLoggerProvider:e.SimpleLoggerProvider,ConsoleAppender:e.ConsoleAppender,LightstreamerJMS:{toString:function(){return"[Lightstreamer JMS Extender JavaScript Client version "+this.version+" build "+this.build+"]"},version:"3.0.1",build:"151"},BytesMessage:q,CompletionListener:ba,Connection:I,ConnectionFactory:pa,ConnectionListener:ra,Destination:fa,ExceptionListener:sa,JMSConsumer:N,JMSContext:P,JMSContextListener:ta,
JMSException:n,JMSProducer:O,MapMessage:u,Message:h,MessageConsumer:C,MessageListener:ka,MessageProducer:B,ObjectMessage:t,Queue:w,QueueConnection:W,QueueConnectionFactory:ua,QueueReceiver:R,QueueSender:S,QueueSession:V,Session:H,TemporaryQueue:y,TemporaryTopic:x,TextMessage:r,Topic:v,TopicConnection:Z,TopicConnectionFactory:va,TopicPublisher:X,TopicSession:Y,TopicSubscriber:G}