You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ea...@apache.org on 2016/02/22 18:16:38 UTC

[1/6] qpid-dispatch git commit: DISPATCH-201: Removing unused files in img/ directory

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 06c2538af -> e1c7255a3


DISPATCH-201: Removing unused files in img/ directory


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/9d0bed0b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/9d0bed0b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/9d0bed0b

Branch: refs/heads/master
Commit: 9d0bed0b8202a9d7dad65c2639e858e2a4c41478
Parents: 06c2538
Author: Ernest Allen <ea...@redhat.com>
Authored: Mon Feb 22 11:56:56 2016 -0500
Committer: Ernest Allen <ea...@redhat.com>
Committed: Mon Feb 22 11:56:56 2016 -0500

----------------------------------------------------------------------
 console/stand-alone/plugin/img/ZeroClipboard.swf    | Bin 1966 -> 0 bytes
 console/stand-alone/plugin/img/ajax-loader.gif      | Bin 3208 -> 0 bytes
 console/stand-alone/plugin/img/dynatree/icons.gif   | Bin 5512 -> 0 bytes
 console/stand-alone/plugin/img/dynatree/loading.gif | Bin 3111 -> 0 bytes
 4 files changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/9d0bed0b/console/stand-alone/plugin/img/ZeroClipboard.swf
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/img/ZeroClipboard.swf b/console/stand-alone/plugin/img/ZeroClipboard.swf
deleted file mode 100644
index a3aaa20..0000000
Binary files a/console/stand-alone/plugin/img/ZeroClipboard.swf and /dev/null differ

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/9d0bed0b/console/stand-alone/plugin/img/ajax-loader.gif
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/img/ajax-loader.gif b/console/stand-alone/plugin/img/ajax-loader.gif
deleted file mode 100644
index 3c2f7c0..0000000
Binary files a/console/stand-alone/plugin/img/ajax-loader.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/9d0bed0b/console/stand-alone/plugin/img/dynatree/icons.gif
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/img/dynatree/icons.gif b/console/stand-alone/plugin/img/dynatree/icons.gif
deleted file mode 100644
index 6e237a0..0000000
Binary files a/console/stand-alone/plugin/img/dynatree/icons.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/9d0bed0b/console/stand-alone/plugin/img/dynatree/loading.gif
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/img/dynatree/loading.gif b/console/stand-alone/plugin/img/dynatree/loading.gif
deleted file mode 100644
index 2a96840..0000000
Binary files a/console/stand-alone/plugin/img/dynatree/loading.gif and /dev/null differ


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[2/6] qpid-dispatch git commit: using minified rhea library

Posted by ea...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/f9ba97fd/console/stand-alone/plugin/lib/rhea-min.js
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/lib/rhea-min.js b/console/stand-alone/plugin/lib/rhea-min.js
new file mode 100644
index 0000000..f61579a
--- /dev/null
+++ b/console/stand-alone/plugin/lib/rhea-min.js
@@ -0,0 +1,93 @@
+require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+(function (process,Buffer){
+"use strict";function get_socket_id(t){return t.get_id_string?t.get_id_string():t.localAddress+":"+t.localPort+" -> "+t.remoteAddress+":"+t.remotePort}function session_per_connection(t){var e=null;return{get_session:function(){return e||(e=t.create_session(),e.begin()),e}}}function restrict(t,e){if(t){var o,n=t;return function(i){return o!==i&&(n=t,o=i),n--?e(i):-1}}return e}function backoff(t,e){var o,n=t;return function(i){o!==i&&(n=t,o=i);var s=n,r=2*n;return n=e>r?r:e,s}}function get_connect_fn(t){if(void 0===t.transport||"tcp"===t.transport)return net.connect;if("tls"===t.transport||"ssl"===t.transport)return tls.connect;throw Error("Unrecognised transport: "+t.transport)}function connection_details(t){var e={};return e.connect=t.connect?t.connect:get_connect_fn(t),e.host=t.host?t.host:"localhost",e.port=t.port?t.port:5672,e.options=t,e}function delegate_to_session(t){Connection.prototype["on_"+t]=function(e){var o=this.remote_channel_map[e.channel];if(!o)throw Error(t+" receiv
 ed on invalid channel "+e.channel);o["on_"+t](e)}}var frames=require("./frames.js"),log=require("./log.js"),sasl=require("./sasl.js"),types=require("./types.js"),util=require("./util.js"),EndpointState=require("./endpoint.js"),Session=require("./session.js"),Transport=require("./transport.js"),net=require("net"),tls=require("tls"),EventEmitter=require("events").EventEmitter,AMQP_PROTOCOL_ID=0,TLS_PROTOCOL_ID=2,conn_counter=1,Connection=function(t,e){if(this.options={},t)for(var o in t)this.options[o]=t[o];if(this.container=e,this.options.id||(this.options.id="connection-"+conn_counter++),this.options.container_id||(this.options.container_id=e?e.id:util.generate_uuid()),!this.options.connection_details){var n=this;this.options.connection_details=function(){return connection_details(n.options)}}var i=this.get_option("reconnect",!0);if("boolean"==typeof i&&i){var s=this.get_option("initial_reconnect_delay",100),r=this.get_option("max_reconnect_delay",6e4);this.options.reconnect=restric
 t(this.get_option("reconnect_limit"),backoff(s,r))}else if("number"==typeof i){var c=this.options.reconnect;this.options.reconnect=restrict(this.get_option("reconnect_limit"),function(){return c})}this.registered=!1,this.state=new EndpointState,this.local_channel_map={},this.remote_channel_map={},this.local={},this.remote={},this.local.open=frames.open(this.options),this.local.close=frames.close({}),this.session_policy=session_per_connection(this),this.amqp_transport=new Transport(this.options.id,AMQP_PROTOCOL_ID,frames.TYPE_AMQP,this),this.sasl_transport=void 0,this.transport=this.amqp_transport,this.conn_established_counter=0,this.heartbeat_out=void 0,this.heartbeat_in=void 0,this.abort_idle=!1,this.socket_ready=!1,this.scheduled_reconnect=void 0};Connection.prototype=Object.create(EventEmitter.prototype),Connection.prototype.constructor=Connection,Connection.prototype.dispatch=function(t,e){return log.events("Connection got event: "+t),this.listeners(t).length?(EventEmitter.proto
 type.emit.apply(this,arguments),!0):this.container?this.container.dispatch.apply(this.container,arguments):void 0},Connection.prototype.reset=function(){this.abort_idle&&(this.abort_idle=!1,this.local.close.error=void 0,this.state=new EndpointState,this.state.open()),this.amqp_transport=new Transport(this.options.id,AMQP_PROTOCOL_ID,frames.TYPE_AMQP,this),this.sasl_transport=void 0,this.transport=this.amqp_transport,this.state.disconnected(),this.remote={},this.remote_channel_map={};for(var t in this.local_channel_map)this.local_channel_map[t].reset();this.socket_ready=!1},Connection.prototype.connect=function(){return this.is_server=!1,this._connect(this.options.connection_details(this.conn_established_counter)),this.open(),this},Connection.prototype.reconnect=function(){return this.scheduled_reconnect=void 0,log.reconnect("reconnecting..."),this.reset(),this._connect(this.options.connection_details(this.conn_established_counter)),process.nextTick(this._process.bind(this)),this},Co
 nnection.prototype._connect=function(t){return t.connect?this.init(t.connect(t.port,t.host,t.options,this.connected.bind(this))):this.init(get_connect_fn(t)(t.port,t.host,t.options,this.connected.bind(this))),this},Connection.prototype.accept=function(t){return this.is_server=!0,log.io("["+this.id+"] client accepted: "+get_socket_id(t)),this.socket_ready=!0,this.init(t)},Connection.prototype.init=function(t){if(this.socket=t,this.socket.on("data",this.input.bind(this)),this.socket.on("error",this.error.bind(this)),this.socket.on("end",this.eof.bind(this)),this.is_server){var e;this.container&&Object.getOwnPropertyNames(this.container.sasl_server_mechanisms).length&&(e=this.container.sasl_server_mechanisms),this.socket.encrypted&&this.socket.authorized&&this.get_option("enable_sasl_external",!1)&&(e=sasl.server_add_external(e?util.clone(e):{})),e&&(this.sasl_transport=new sasl.Server(this,e))}else{var o=this.get_option("sasl_mechanisms");if(!o){var n=this.get_option("username"),i=thi
 s.get_option("password");n&&(o=sasl.client_mechanisms(),i?o.enable_plain(n,i):o.enable_anonymous(n))}this.socket.encrypted&&this.options.cert&&this.get_option("enable_sasl_external",!1)&&(o||(o=sasl.client_mechanisms()),o.enable_external()),o&&(this.sasl_transport=new sasl.Client(this,o))}return this.transport=this.sasl_transport?this.sasl_transport:this.amqp_transport,this},Connection.prototype.attach_sender=function(t){return this.session_policy.get_session().attach_sender(t)},Connection.prototype.open_sender=Connection.prototype.attach_sender,Connection.prototype.attach_receiver=function(t){return this.session_policy.get_session().attach_receiver(t)},Connection.prototype.open_receiver=Connection.prototype.attach_receiver,Connection.prototype.get_option=function(t,e){return void 0!==this.options[t]?this.options[t]:this.container?this.container.get_option(t,e):e},Connection.prototype.connected=function(){this.socket_ready=!0,this.conn_established_counter++,log.io("["+this.options.i
 d+"] connected "+get_socket_id(this.socket)),this.output()},Connection.prototype.sasl_failed=function(t){this.transport_error={condition:"amqp:unauthorized-access",description:t},this._handle_error()},Connection.prototype._handle_error=function(){var t=this.get_error();return t?(this.dispatch("connection_error",this._context())||this.dispatch("connection_close",this._context())||console.log("error: "+JSON.stringify(t)),!0):!1},Connection.prototype.get_error=function(){return this.transport_error?this.transport_error:this.remote.close&&this.remote.close.error?this.remote.close.error:void 0},Connection.prototype.output=function(){this.socket&&this.socket_ready&&(this.heartbeat_out&&clearTimeout(this.heartbeat_out),this.transport.write(this.socket),(this.is_closed()&&this.state.has_settled()||this.abort_idle||this.transport_error)&&!this.transport.has_writes_pending()?this.socket.end():this.is_open()&&this.remote.open.idle_time_out&&(this.heartbeat_out=setTimeout(this._write_frame.bind
 (this),this.remote.open.idle_time_out/2)))},Connection.prototype.input=function(t){this.heartbeat_in&&clearTimeout(this.heartbeat_in),log.io("["+this.options.id+"] read "+t.length+" bytes");var e;this.previous_input?(e=Buffer.concat([this.previous_input,t],this.previous_input.length+t.length),this.previous_input=null):e=t;var o=this.transport.read(e,this);o<e.length&&(this.previous_input=e.slice(o)),this.local.open.idle_time_out&&(this.heartbeat_in=setTimeout(this.idle.bind(this),this.local.open.idle_time_out)),this.transport.has_writes_pending()&&this.output()},Connection.prototype.idle=function(){this.is_open()&&(this.abort_idle=!0,this.local.close.error={condition:"amqp:resource-limit-exceeded",description:"max idle time exceeded"},this.close())},Connection.prototype.error=function(t){console.log("["+this.options.id+"] error: "+t),this._disconnected()},Connection.prototype.eof=function(t){this._disconnected()},Connection.prototype._disconnected=function(){if(!this.is_closed()&&vo
 id 0==this.scheduled_reconnect&&(this.dispatch("disconnected",this._context())||console.log("["+this.options.id+"] disconnected"),!this.is_server&&!this.transport_error&&this.options.reconnect)){var t=this.options.reconnect(this.conn_established_counter);t>=0&&(log.reconnect("Scheduled reconnect in "+t+"ms"),this.scheduled_reconnect=setTimeout(this.reconnect.bind(this),t))}},Connection.prototype.open=function(){this.state.open()&&this._register()},Connection.prototype.close=function(){this.state.close()&&this._register()},Connection.prototype.is_open=function(){return this.state.is_open()},Connection.prototype.is_closed=function(){return this.state.is_closed()},Connection.prototype.create_session=function(){for(var t=0;this.local_channel_map[t];)t++;var e=new Session(this,t);return this.local_channel_map[t]=e,e},Connection.prototype.on_open=function(t){if(!this.state.remote_opened())throw Error("Open already received");this.remote.open=t.performative,this.open(),this.dispatch("conne
 ction_open",this._context())},Connection.prototype.on_close=function(t){if(!this.state.remote_closed())throw Error("Close already received");this.remote.close=t.performative,this.close(),this.remote.close.error?this._handle_error():this.dispatch("connection_close",this._context()),this.heartbeat_out&&clearTimeout(this.heartbeat_out)},Connection.prototype._register=function(){this.registered||(this.registered=!0,process.nextTick(this._process.bind(this)))},Connection.prototype._process=function(){this.registered=!1;do{this.state.need_open()&&this._write_open();for(var t in this.local_channel_map)this.local_channel_map[t]._process();this.state.need_close()&&this._write_close()}while(!this.state.has_settled())},Connection.prototype._write_frame=function(t,e,o){this.amqp_transport.encode(frames.amqp_frame(t,e,o)),this.output()},Connection.prototype._write_open=function(){this._write_frame(0,this.local.open.described())},Connection.prototype._write_close=function(){this._write_frame(0,th
 is.local.close.described())},Connection.prototype.on_begin=function(t){var e;if(null===t.performative.remote_channel||void 0===t.performative.remote_channel)e=this.create_session(),e.local.begin.remote_channel=t.channel;else if(e=this.local_channel_map[t.performative.remote_channel],!e)throw Error("Invalid value for remote channel "+t.performative.remote_channel);e.on_begin(t),this.remote_channel_map[t.channel]=e},Connection.prototype.get_peer_certificate=function(){return this.socket&&this.socket.getPeerCertificate?this.socket.getPeerCertificate():void 0},Connection.prototype._context=function(t){var e=t?t:{};return e.connection=this,this.container&&(e.container=this.container),e},delegate_to_session("end"),delegate_to_session("attach"),delegate_to_session("detach"),delegate_to_session("transfer"),delegate_to_session("disposition"),delegate_to_session("flow"),module.exports=Connection;
+}).call(this,require('_process'),require("buffer").Buffer)
+
+},{"./endpoint.js":2,"./frames.js":3,"./log.js":5,"./sasl.js":8,"./session.js":9,"./transport.js":11,"./types.js":12,"./util.js":13,"_process":24,"buffer":19,"events":23,"net":18,"tls":18}],2:[function(require,module,exports){
+"use strict";var EndpointState=function(){this.init()};EndpointState.prototype.init=function(){this.local_open=!1,this.remote_open=!1,this.open_requests=0,this.close_requests=0,this.initialised=!1},EndpointState.prototype.open=function(){return this.initialised=!0,this.local_open?!1:(this.local_open=!0,this.open_requests++,!0)},EndpointState.prototype.close=function(){return this.local_open?(this.local_open=!1,this.close_requests++,!0):!1},EndpointState.prototype.disconnected=function(){var t=this.local_open;this.init(),t?this.open():this.close()},EndpointState.prototype.remote_opened=function(t){return this.remote_open?!1:(this.remote_open=!0,!0)},EndpointState.prototype.remote_closed=function(t){return this.remote_open?(this.remote_open=!1,!0):!1},EndpointState.prototype.is_open=function(){return this.local_open&&this.remote_open},EndpointState.prototype.is_closed=function(){return this.initialised&&!this.local_open&&!this.remote_open},EndpointState.prototype.has_settled=function(
 ){return 0==this.open_requests&&0==this.close_requests},EndpointState.prototype.need_open=function(){return this.open_requests>0?(this.open_requests--,!0):!1},EndpointState.prototype.need_close=function(){return this.close_requests>0?(this.close_requests--,!0):!1},module.exports=EndpointState;
+},{}],3:[function(require,module,exports){
+"use strict";function define_frame(e,a){var t=types.define_composite(a);frames[a.name]=t.create,by_descriptor[Number(t.descriptor.numeric).toString(10)]=t,by_descriptor[t.descriptor.symbolic]=t}var types=require("./types.js"),frames={},by_descriptor={};frames.read_header=function(e){var a=4,t={},n=e.toString("ascii",0,a);if("AMQP"!==n)throw Error("Invalid protocol header for AMQP "+n);if(t.protocol_id=e.readUInt8(a++),t.major=e.readUInt8(a++),t.minor=e.readUInt8(a++),t.revision=e.readUInt8(a++),1!==t.major||0!==t.minor)throw Error("Unsupported AMQP version: "+JSON.stringify(t));return t},frames.write_header=function(e,a){var t=4;return e.write("AMQP",0,t,"ascii"),e.writeUInt8(a.protocol_id,t++),e.writeUInt8(a.major,t++),e.writeUInt8(a.minor,t++),e.writeUInt8(a.revision,t++),8},frames.TYPE_AMQP=0,frames.TYPE_SASL=1,frames.read_frame=function(e){var a=new types.Reader(e),t={};if(t.size=a.read_uint(4),a.remaining<t.size)return null;var n=a.read_uint(1);if(2>n)throw Error("Invalid data 
 offset, must be at least 2 was "+n);if(t.type=a.read_uint(1),t.type===frames.TYPE_AMQP)t.channel=a.read_uint(2);else{if(t.type!==frames.TYPE_SASL)throw Error("Unknown frame type "+t.type);a.skip(2)}if(n>1&&a.skip(4*n-8),a.remaining()){t.performative=a.read();var r=by_descriptor[t.performative.descriptor.value];r&&(t.performative=new r(t.performative.value)),a.remaining()&&(t.payload=a.read_bytes(a.remaining()))}return t},frames.write_frame=function(e){var a=new types.Writer;if(a.skip(4),a.write_uint(2,1),a.write_uint(e.type,1),e.type===frames.TYPE_AMQP)a.write_uint(e.channel,2);else{if(e.type!==frames.TYPE_SASL)throw Error("Unknown frame type "+e.type);a.write_uint(0,2)}e.performative&&(a.write(e.performative),e.payload&&a.write_bytes(e.payload));var t=a.toBuffer();return t.writeUInt32BE(t.length,0),t},frames.amqp_frame=function(e,a,t){return{channel:e||0,type:frames.TYPE_AMQP,performative:a,payload:t}},frames.sasl_frame=function(e){return{channel:0,type:frames.TYPE_SASL,performativ
 e:e}};var open={name:"open",code:16,fields:[{name:"container_id",type:"string",mandatory:!0},{name:"hostname",type:"string"},{name:"max_frame_size",type:"uint",default_value:4294967295},{name:"channel_max",type:"ushort",default_value:65535},{name:"idle_time_out",type:"uint"},{name:"outgoing_locales",type:"symbol",multiple:!0},{name:"incoming_locales",type:"symbol",multiple:!0},{name:"offered_capabilities",type:"symbol",multiple:!0},{name:"desired_capabilities",type:"symbol",multiple:!0},{name:"properties",type:"symbolic_map"}]},begin={name:"begin",code:17,fields:[{name:"remote_channel",type:"ushort"},{name:"next_outgoing_id",type:"uint",mandatory:!0},{name:"incoming_window",type:"uint",mandatory:!0},{name:"outgoing_window",type:"uint",mandatory:!0},{name:"handle_max",type:"uint",default_value:"4294967295"},{name:"offered_capabilities",type:"symbol",multiple:!0},{name:"desired_capabilities",type:"symbol",multiple:!0},{name:"properties",type:"symbolic_map"}]},attach={name:"attach",cod
 e:18,fields:[{name:"name",type:"string",mandatory:!0},{name:"handle",type:"uint",mandatory:!0},{name:"role",type:"boolean",mandatory:!0},{name:"snd_settle_mode",type:"ubyte",default_value:2},{name:"rcv_settle_mode",type:"ubyte",default_value:0},{name:"source",type:"*"},{name:"target",type:"*"},{name:"unsettled",type:"map"},{name:"incomplete_unsettled",type:"boolean",default_value:!1},{name:"initial_delivery_count",type:"uint"},{name:"max_message_size",type:"ulong"},{name:"offered_capabilities",type:"symbol",multiple:!0},{name:"desired_capabilities",type:"symbol",multiple:!0},{name:"properties",type:"symbolic_map"}]},flow={name:"flow",code:19,fields:[{name:"next_incoming_id",type:"uint"},{name:"incoming_window",type:"uint",mandatory:!0},{name:"next_outgoing_id",type:"uint",mandatory:!0},{name:"outgoing_window",type:"uint",mandatory:!0},{name:"handle",type:"uint"},{name:"delivery_count",type:"uint"},{name:"link_credit",type:"uint"},{name:"available",type:"uint"},{name:"drain",type:"bo
 olean",default_value:!1},{name:"echo",type:"boolean",default_value:!1},{name:"properties",type:"symbolic_map"}]},transfer={name:"transfer",code:20,fields:[{name:"handle",type:"uint",mandatory:!0},{name:"delivery_id",type:"uint"},{name:"delivery_tag",type:"binary"},{name:"message_format",type:"uint"},{name:"settled",type:"boolean"},{name:"more",type:"boolean",default_value:!1},{name:"rcv_settle_mode",type:"ubyte"},{name:"state",type:"delivery_state"},{name:"resume",type:"boolean",default_value:!1},{name:"aborted",type:"boolean",default_value:!1},{name:"batchable",type:"boolean",default_value:!1}]},disposition={name:"disposition",code:21,fields:[{name:"role",type:"boolean",mandatory:!0},{name:"first",type:"uint",mandatory:!0},{name:"last",type:"uint"},{name:"settled",type:"boolean",default_value:!1},{name:"state",type:"*"},{name:"batchable",type:"boolean",default_value:!1}]},detach={name:"detach",code:22,fields:[{name:"handle",type:"uint",mandatory:!0},{name:"closed",type:"boolean",de
 fault_value:!1},{name:"error",type:"error"}]},end={name:"end",code:23,fields:[{name:"error",type:"error"}]},close={name:"close",code:24,fields:[{name:"error",type:"error"}]};define_frame(frames.TYPE_AMQP,open),define_frame(frames.TYPE_AMQP,begin),define_frame(frames.TYPE_AMQP,attach),define_frame(frames.TYPE_AMQP,flow),define_frame(frames.TYPE_AMQP,transfer),define_frame(frames.TYPE_AMQP,disposition),define_frame(frames.TYPE_AMQP,detach),define_frame(frames.TYPE_AMQP,end),define_frame(frames.TYPE_AMQP,close);var sasl_mechanisms={name:"sasl_mechanisms",code:64,fields:[{name:"sasl_server_mechanisms",type:"symbol",multiple:!0,mandatory:!0}]},sasl_init={name:"sasl_init",code:65,fields:[{name:"mechanism",type:"symbol",mandatory:!0},{name:"initial_response",type:"binary"},{name:"hostname",type:"string"}]},sasl_challenge={name:"sasl_challenge",code:66,fields:[{name:"challenge",type:"binary",mandatory:!0}]},sasl_response={name:"sasl_response",code:67,fields:[{name:"response",type:"binary",m
 andatory:!0}]},sasl_outcome={name:"sasl_outcome",code:68,fields:[{name:"code",type:"ubyte",mandatory:!0},{name:"additional_data",type:"binary"}]};define_frame(frames.TYPE_SASL,sasl_mechanisms),define_frame(frames.TYPE_SASL,sasl_init),define_frame(frames.TYPE_SASL,sasl_challenge),define_frame(frames.TYPE_SASL,sasl_response),define_frame(frames.TYPE_SASL,sasl_outcome),module.exports=frames;
+},{"./types.js":12}],4:[function(require,module,exports){
+"use strict";function auto_settle(e){e.delivery.settled=!0}function auto_accept(e){e.delivery.update(!0,message.accepted().described())}function is_internal(e){switch(e){case"handle":case"role":case"initial_delivery_count":return!0;default:return!1}}var frames=require("./frames.js"),log=require("./log.js"),message=require("./message.js"),terminus=require("./terminus.js"),types=require("./types.js"),EndpointState=require("./endpoint.js"),FlowController=function(e){this.window=e};FlowController.prototype.update=function(e){var t=this.window-e.receiver.credit;e.receiver.flow(t)};var EventEmitter=require("events").EventEmitter,link=Object.create(EventEmitter.prototype);link.dispatch=function(e,t){log.events("Link got event: "+e),EventEmitter.prototype.emit.apply(this.observers,arguments),this.listeners(e).length?EventEmitter.prototype.emit.apply(this,arguments):this.session.dispatch.apply(this.session,arguments)},link.set_source=function(e){this.local.attach.source=terminus.source(e).de
 scribed()},link.set_target=function(e){this.local.attach.target=terminus.target(e).described()},link.attach=function(){this.state.open()&&this.connection._register()},link.open=link.attach,link.detach=function(){this.local.detach.closed=!1,this.state.close()&&this.connection._register()},link.close=function(){this.local.detach.closed=!0,this.state.close()&&this.connection._register()},link.is_open=function(){return this.session.is_open()&&this.state.is_open()},link.is_closed=function(){return this.session.is_closed()||this.state.is_closed()},link._process=function(){do this.state.need_open()&&this.session.output(this.local.attach.described()),this.issue_flow&&(this.session._write_flow(this),this.issue_flow=!1),this.state.need_close()&&this.session.output(this.local.detach.described());while(!this.state.has_settled())},link.on_attach=function(e){if(!this.state.remote_opened())throw Error("Attach already received");this.remote.handle||(this.remote.handle=e.handle),e.performative.sourc
 e=terminus.unwrap(e.performative.source),e.performative.target=terminus.unwrap(e.performative.target),this.remote.attach=e.performative,this.open(),this.dispatch(this.is_receiver()?"receiver_open":"sender_open",this._context())},link.on_detach=function(e){if(!this.state.remote_closed())throw Error("Detach already received");this.remote.detach=e.performative,this.close(),this.dispatch(this.local.attach.role?"receiver_close":"sender_close",this._context())},link.init=function(e,t,i,s,n){this.session=e,this.connection=e.connection,this.name=t,this.options=void 0===s?{}:s,this.state=new EndpointState,this.issue_flow=!1,this.local={handle:i},this.local.attach=frames.attach({handle:i,name:t,role:n});for(var o in this.local.attach)is_internal(o)||void 0===this.options[o]||(this.local.attach[o]=this.options[o]);this.local.detach=frames.detach({handle:i,closed:!0}),this.remote={handle:void 0},this.delivery_count=0,this.credit=0,this.observers=new EventEmitter},link.reset=function(){this.stat
 e.disconnected(),this.remote={handle:void 0},this.delivery_count=0,this.credit=0},link.has_credit=function(){return this.credit>0},link.is_receiver=function(){return this.local.attach.role},link._context=function(e){var t=e?e:{};return this.is_receiver()?t.receiver=this:t.sender=this,this.session._context(t)},link.get_option=function(e,t){return void 0!==this.options[e]?this.options[e]:this.session.get_option(e,t)};var Sender=function(e,t,i,s){this.init(e,t,i,s,!1),this.local.attach.initial_delivery_count=0,this.tag=0,this.get_option("autosettle",!0)&&this.observers.on("settled",auto_settle)};Sender.prototype=Object.create(link),Sender.prototype.constructor=Sender,Sender.prototype.next_tag=function(){return new String(this.tag++)},Sender.prototype.sendable=function(e){return this.credit&&this.session.outgoing.available()},Sender.prototype.on_flow=function(e){var t=e.performative;this.credit=t.delivery_count+t.link_credit-this.delivery_count,this.is_open()&&(this.dispatch("sender_flo
 w",this._context()),this.sendable()&&this.dispatch("sendable",this._context()))},Sender.prototype.on_transfer=function(e){throw Error("got transfer on sending link")},Sender.prototype.send=function(e,t){return this.session.send(this,t?t:this.next_tag(),message.encode(e),0)};var Receiver=function(e,t,i,s){this.init(e,t,i,s,!0),this.set_prefetch(this.get_option("prefetch",100)),this.get_option("autoaccept",!0)&&this.observers.on("message",auto_accept)};Receiver.prototype=Object.create(link),Receiver.prototype.constructor=Receiver,Receiver.prototype.on_flow=function(e){this.dispatch("receiver_flow",this._context())},Receiver.prototype.flow=function(e){e>0&&(this.credit+=e,this.issue_flow=!0,this.connection._register())},Receiver.prototype.set_prefetch=function(e){if(e>0){var t=new FlowController(e),i=t.update.bind(t);this.observers.on("message",i),this.observers.on("receiver_open",i)}},module.exports={Sender:Sender,Receiver:Receiver};
+},{"./endpoint.js":2,"./frames.js":3,"./log.js":5,"./message.js":6,"./terminus.js":10,"./types.js":12,"events":23}],5:[function(require,module,exports){
+"use strict";var debug=require("debug");module.exports={frames:debug("rhea:frames"),raw:debug("rhea:raw"),reconnect:debug("rhea:reconnect"),events:debug("rhea:events"),message:debug("rhea:message"),flow:debug("rhea:flow"),io:debug("rhea:io")};
+},{"debug":15}],6:[function(require,module,exports){
+"use strict";function define_section(e,n,t){n.descriptor=e,unwrappers[e.symbolic]=n,unwrappers[Number(e.numeric).toString(10)]=n,t&&wrappers.push(t)}function define_composite_section(e){var n=types.define_composite(e);message[e.name]=n.create,by_descriptor[Number(n.descriptor.numeric).toString(10)]=n,by_descriptor[n.descriptor.symbolic]=n;var t=function(t,o){t[e.name]=new n(o.value)},o=function(t,o){o[e.name]&&(o[e.name].described?t.push(o[e.name].described()):t.push(n.create(o[e.name]).described()))};define_section(n.descriptor,t,o)}function define_map_section(e){var n={numeric:e.code};n.symbolic="amqp:"+e.name.replace(/_/g,"-")+":map";var t=function(n,t){n[e.name]=types.unwrap(t)},o=function(t,o){o[e.name]&&t.push(types.described(types.wrap_ulong(n.numeric),types.wrap_map(o[e.name])))};define_section(n,t,o)}function define_outcome(e){var n=types.define_composite(e);n.composite_type=e.name,message[e.name]=n.create,outcomes[Number(n.descriptor.numeric).toString(10)]=n,outcomes[n.des
 criptor.symbolic]=n,message["is_"+e.name]=function(n){if(n&&n.descriptor){var t=outcomes[n.descriptor.value];if(t)return t.descriptor.numeric==e.code}return!1}}var log=require("./log.js"),types=require("./types.js"),by_descriptor={},unwrappers={},wrappers=[],message={};define_composite_section({name:"header",code:112,fields:[{name:"durable",type:"boolean",default_value:!1},{name:"priority",type:"ubyte",default_value:4},{name:"ttl",type:"uint"},{name:"first_acquirer",type:"boolean",default_value:!1},{name:"delivery_count",type:"uint",default_value:0}]}),define_map_section({name:"delivery_annotations",code:113}),define_map_section({name:"message_annotations",code:114}),define_composite_section({name:"properties",code:115,fields:[{name:"message_id",type:"message_id"},{name:"user_id",type:"binary"},{name:"to",type:"string"},{name:"subject",type:"string"},{name:"reply_to",type:"string"},{name:"correlation_id",type:"message_id"},{name:"content_type",type:"symbol"},{name:"content_encoding"
 ,type:"symbol"},{name:"absolute_expiry_time",type:"timestamp"},{name:"creation_time",type:"timestamp"},{name:"group_id",type:"string"},{name:"group_sequence",type:"uint"},{name:"reply_to_group_id",type:"string"}]}),define_map_section({name:"application_properties",code:116}),define_section({numeric:119,symbolic:"amqp:value:*"},function(e,n){e.body=types.unwrap(n)},function(e,n){e.push(types.described(types.wrap_ulong(119),types.wrap(n.body)))}),define_map_section({name:"footer",code:120}),message.encode=function(e){var n=[];wrappers.forEach(function(t){t(n,e)});for(var t=new types.Writer,o=0;o<n.length;o++)log.message("Encoding section "+(o+1)+" of "+n.length+": "+n[o]),t.write(n[o]);var i=t.toBuffer();return log.message("encoded "+i.length+" bytes"),i},message.decode=function(e){for(var n={},t=new types.Reader(e);t.remaining();){var o=t.read();if(log.message("decoding section: "+JSON.stringify(o)+" of type: "+JSON.stringify(o.descriptor)),o.descriptor){var i=unwrappers[o.descriptor
 .value];i?i(n,o):console.log("WARNING: did not recognise message section with descriptor "+o.descriptor)}else console.log("WARNING: expected described message section got "+JSON.stringify(o))}return n};var outcomes={};message.unwrap_outcome=function(e){if(e&&e.descriptor){var n=outcomes[e.descriptor.value];if(n)return new n(e)}return console.log("unrecognised outcome"),e},message.are_outcomes_equivalent=function(e,n){return void 0===e&&void 0===n?!0:void 0===e||void 0===n?!1:e.descriptor.value==n.descriptor.value&&JSON.stringify(e)==JSON.stringify(n)},define_outcome({name:"received",code:35,fields:[{name:"section-number",type:"uint",mandatory:!0},{name:"section-offset",type:"ulong",mandatory:!0}]}),define_outcome({name:"accepted",code:36,fields:[]}),define_outcome({name:"rejected",code:37,fields:[{name:"error",type:"error"}]}),define_outcome({name:"released",code:38,fields:[]}),define_outcome({name:"modified",code:39,fields:[{name:"delivery-failed",type:"boolean"},{name:"undeliverab
 le-here",type:"boolean"},{name:"message-annotations",type:"fields"}]}),module.exports=message;
+},{"./log.js":5,"./types.js":12}],7:[function(require,module,exports){
+"use strict";function match(e,t){return t?Array.isArray(t)?t.indexOf(e)>-1:e===t:!1}var url=require("url"),simple_id_generator={counter:1,next:function(){return this.counter++}},Client=function(e,t){var i=url.parse(t);this.connection=e.connect({host:i.hostname,port:i.port}),this.connection.on("message",this._response.bind(this)),this.connection.on("receiver_open",this._ready.bind(this)),this.sender=this.connection.attach_sender(i.path.substr(1)),this.receiver=this.connection.attach_receiver({source:{dynamic:!0}}),this.id_generator=simple_id_generator,this.pending=[],this.outstanding={}};Client.prototype._request=function(e,t,i,n){var s={properties:{}};s.properties.subject=t,s.body=i,s.properties.message_id=e,s.properties.reply_to=this.receiver.remote.attach.source.address,this.outstanding[e]=n,this.sender.send(s)},Client.prototype._response=function(e){var t=e.message.properties.correlation_id,i=this.outstanding[t];i?"ok"===e.message.properties.subject?i(e.message.body):i(void 0,{na
 me:e.message.properties.subject,description:e.message.body}):console.log("no request pending for "+t+", ignoring response")},Client.prototype._ready=function(e){this._process_pending()},Client.prototype._process_pending=function(){for(var e=0;e<this.pending.length;e++){var t=this.pending[e];this._request(t.id,t.name,t.args,t.callback)}this.pending=[]},Client.prototype.call=function(e,t,i){var n=this.id_generator.next();this.receiver.is_open()&&0===this.pending.length?this._request(n,e,t,i):this.pending.push({name:e,args:t,callback:i,id:n})},Client.prototype.close=function(){this.receiver.close(),this.sender.close(),this.connection.close()},Client.prototype.define=function(e){this[e]=function(t,i){this.call(e,t,i)}};var Cache=function(e,t){this.ttl=e,this.purged=t,this.entries={},this.timeout=void 0};Cache.prototype.clear=function(){this.timeout&&clearTimeout(this.timeout),this.entries={}},Cache.prototype.put=function(e,t){this.entries[e]={value:t,last_accessed:Date.now()},this.timeo
 ut||(this.timeout=setTimeout(this.purge.bind(this),this.ttl))},Cache.prototype.get=function(e){var t=this.entries[e];return t?(t.last_accessed=Date.now(),t.value):void 0},Cache.prototype.purge=function(){var e=Date.now(),t=[],i=0;for(var n in this.entries)e-this.entries[n].last_accessed>=this.ttl?t.push(n):i++;for(var s=0;s<t.length;s++){var o=this.entries[t[s]];delete this.entries[t[s]],this.purged(o.value)}i&&!this.timeout&&(this.timeout=setTimeout(this.purge.bind(this),this.ttl))};var LinkCache=function(e,t){this.factory=e,this.cache=new Cache(t,function(e){e.close()})};LinkCache.prototype.clear=function(){this.cache.clear()},LinkCache.prototype.get=function(e){var t=this.cache.get(e);return void 0===t&&(t=this.factory(e),this.cache.put(e,t)),t};var Server=function(e,t,i){this.options=i||{};var n=url.parse(t);this.connection=e.connect({host:n.hostname,port:n.port}),this.connection.on("connection_open",this._connection_open.bind(this)),this.connection.on("message",this._request.bi
 nd(this)),this.receiver=this.connection.attach_receiver(n.path.substr(1)),this.callbacks={},this._send=void 0,this._clear=void 0};Server.prototype._connection_open=function(e){if(match("ANONYMOUS-RELAY",this.connection.remote.open.offered_capabilities)){var t=this.connection.attach_sender({target:{}});this._send=function(e){t.send(e)}}else{var i=new LinkCache(this.connection.attach_sender.bind(this.connection),this.options.cache_ttl||6e4);this._send=function(e){var t=i.get(e.properties.to);t&&t.send(e)},this._clear=function(){i.clear()}}},Server.prototype._respond=function(e){var t=this;return function(i,n){n?(e.properties.subject=n.name||"error",e.body=n.description||n):(e.properties.subject="ok",e.body=i),t._send(e)}},Server.prototype._request=function(e){var t=e.message,i={properties:{}};i.properties.to=t.properties.reply_to,i.properties.correlation_id=t.properties.message_id;var n=this.callbacks[t.properties.subject];n?n(t.body,this._respond(i)):(i.properties.subject="bad-method
 ",i.body="Unrecognised method "+t.properties.subject,this._send(i))},Server.prototype.bind_sync=function(e,t){this.callbacks[t||e.name]=function(t,i){var n=e(t);i(n)}},Server.prototype.bind=function(e,t){this.callbacks[t||e.name]=e},Server.prototype.close=function(){this._clear&&this._clear(),this.receiver.close(),this.connection.close()},module.exports={server:function(e,t,i){return new Server(e,t,i)},client:function(e,t){return new Client(e,t)}};
+},{"url":29}],8:[function(require,module,exports){
+(function (Buffer){
+"use strict";function intersection(e,t){return e.filter(function(e){return t.indexOf(e)>=0})}function extract(e){for(var t=[],s=0,n=0;n<e.length;)0===e[n]?(n>s?t.push(e.toString("utf8",s,n)):t.push(null),s=++n):++n;return n>s?t.push(e.toString("utf8",s,n)):t.push(null),t}var frames=require("./frames.js"),log=require("./log.js"),Transport=require("./transport.js"),sasl_codes={OK:0,AUTH:1,SYS:2,SYS_PERM:3,SYS_TEMP:4},SASL_PROTOCOL_ID=3,PlainServer=function(e){this.callback=e,this.outcome=void 0,this.username=void 0};PlainServer.prototype.start=function(e){var t=extract(e);3!==t.length&&this.connection.sasl_failed("Unexpected response in PLAIN, got "+t.length+" fields, expected 3"),this.callback(t[1],t[2])?(this.outcome=!0,this.username=t[1]):this.outcome=!1};var PlainClient=function(e,t){this.username=e,this.password=t};PlainClient.prototype.start=function(){var e=new Buffer(1+this.username.length+1+this.password.length);return e.writeUInt8(0,0),e.write(this.username,1),e.writeUInt8(0
 ,1+this.username.length),e.write(this.password,1+this.username.length+1),e};var AnonymousServer=function(){this.outcome=void 0,this.username=void 0};AnonymousServer.prototype.start=function(e){this.outcome=!0,this.username=e?e.toString("utf8"):"anonymous"};var AnonymousClient=function(e){this.username=e?e:"anonymous"};AnonymousClient.prototype.start=function(){var e=new Buffer(1+this.username.length);return e.writeUInt8(0,0),e.write(this.username,1),e};var ExternalServer=function(){this.outcome=void 0,this.username=void 0};ExternalServer.prototype.start=function(e){this.outcome=!0};var ExternalClient=function(){this.username=void 0};ExternalClient.prototype.start=function(){return null};var SaslServer=function(e,t){this.connection=e,this.transport=new Transport(e.amqp_transport.identifier,SASL_PROTOCOL_ID,frames.TYPE_SASL,this),this.next=e.amqp_transport,this.mechanisms=t,this.mechanism=void 0,this.outcome=void 0,this.username=void 0;var s=Object.getOwnPropertyNames(t);this.transpor
 t.encode(frames.sasl_frame(frames.sasl_mechanisms({sasl_server_mechanisms:s}).described()))};SaslServer.prototype.do_step=function(e){void 0===this.mechanism.outcome?this.transport.encode(frames.sasl_frame(frames.sasl_challenge({challenge:e}).described())):(this.outcome=this.mechanism.outcome?sasl_codes.OK:sasl_codes.AUTH,this.transport.encode(frames.sasl_frame(frames.sasl_outcome({code:this.outcome}).described())),this.outcome===sasl_codes.OK&&(this.username=this.mechanism.username,this.transport.write_complete=!0,this.transport.read_complete=!0))},SaslServer.prototype.on_sasl_init=function(e){var t=this.mechanisms[e.performative.mechanism];if(t){this.mechanism=t();var s=this.mechanism.start(e.performative.initial_response);this.do_step(s)}else this.outcome=sasl_codes.AUTH,this.transport.encode(frames.sasl_frame(frames.sasl_outcome({code:this.outcome}).described()))},SaslServer.prototype.on_sasl_response=function(e){this.do_step(this.mechanism.step(e.performative.response))},SaslSe
 rver.prototype.has_writes_pending=function(){return this.transport.has_writes_pending()||this.next.has_writes_pending()},SaslServer.prototype.write=function(e){return this.transport.write_complete&&0===this.transport.pending.length?this.next.write(e):this.transport.write(e)},SaslServer.prototype.read=function(e){return this.transport.read_complete?this.next.read(e):this.transport.read(e)};var SaslClient=function(e,t){this.connection=e,this.transport=new Transport(e.amqp_transport.identifier,SASL_PROTOCOL_ID,frames.TYPE_SASL,this),this.next=e.amqp_transport,this.mechanisms=t,this.mechanism=void 0,this.mechanism_name=void 0,this.failed=!1};SaslClient.prototype.on_sasl_mechanisms=function(e){for(var t=0;void 0===this.mechanism&&t<e.performative.sasl_server_mechanisms.length;t++){var s=e.performative.sasl_server_mechanisms[t],n=this.mechanisms[s];n&&(this.mechanism=n(),this.mechanism_name=s)}if(this.mechanism){var r=this.mechanism.start();this.transport.encode(frames.sasl_frame(frames.s
 asl_init({mechanism:this.mechanism_name,initial_response:r}).described()))}else this.failed=!0,this.connection.sasl_failed("No suitable mechanism; server supports "+e.performative.sasl_server_mechanisms)},SaslClient.prototype.on_sasl_challenge=function(e){var t=this.mechanism.step(e.performative.challenge);this.transport.encode(frames.sasl_frame(frames.sasl_response({response:t}).described()))},SaslClient.prototype.on_sasl_outcome=function(e){switch(e.performative.code){case sasl_codes.OK:this.transport.read_complete=!0,this.transport.write_complete=!0;break;default:this.transport.write_complete=!0,this.connection.sasl_failed("Failed to authenticate: "+e.performative.code)}},SaslClient.prototype.has_writes_pending=function(){return this.transport.has_writes_pending()||this.next.has_writes_pending()},SaslClient.prototype.write=function(e){return this.transport.write_complete?this.next.write(e):this.transport.write(e)},SaslClient.prototype.read=function(e){return this.transport.read_c
 omplete?this.next.read(e):this.transport.read(e)};var default_server_mechanisms={enable_anonymous:function(){this.ANONYMOUS=function(){return new AnonymousServer}},enable_plain:function(e){this.PLAIN=function(){return new PlainServer(e)}}},default_client_mechanisms={enable_anonymous:function(e){this.ANONYMOUS=function(){return new AnonymousClient(e)}},enable_plain:function(e,t){this.PLAIN=function(){return new PlainClient(e,t)}},enable_external:function(){this.EXTERNAL=function(){return new ExternalClient}}};module.exports={Client:SaslClient,Server:SaslServer,server_mechanisms:function(){return Object.create(default_server_mechanisms)},client_mechanisms:function(){return Object.create(default_client_mechanisms)},server_add_external:function(e){return e.EXTERNAL=function(){return new ExternalServer},e}};
+}).call(this,require("buffer").Buffer)
+
+},{"./frames.js":3,"./log.js":5,"./transport.js":11,"buffer":19}],9:[function(require,module,exports){
+(function (Buffer){
+"use strict";function attach(e,t,i){var o=t?t:{};"string"==typeof t&&(o={},o[i]=t),o.name||(o.name=util.generate_uuid());var n=e(o.name,o);for(var s in{source:0,target:0})o[s]&&("string"==typeof o[s]&&(o[s]={address:o[s]}),n["set_"+s](o[s]));return n.attach(),n}var frames=require("./frames.js"),link=require("./link.js"),log=require("./log.js"),message=require("./message.js"),types=require("./types.js"),util=require("./util.js"),EndpointState=require("./endpoint.js"),EventEmitter=require("events").EventEmitter,CircularBuffer=function(e){this.capacity=e,this.size=0,this.head=0,this.tail=0,this.entries=[]};CircularBuffer.prototype.available=function(){return this.capacity-this.size},CircularBuffer.prototype.push=function(e){if(!(this.size<this.capacity))throw Error("circular buffer overflow: head="+this.head+" tail="+this.tail+" size="+this.size+" capacity="+this.capacity);this.entries[this.tail]=e,this.tail=(this.tail+1)%this.capacity,this.size++},CircularBuffer.prototype.pop_if=funct
 ion(e){for(var t=0;this.size&&e(this.entries[this.head]);)this.entries[this.head]=void 0,this.head=(this.head+1)%this.capacity,this.size--,t++;return t},CircularBuffer.prototype.by_id=function(e){if(this.size>0){var t=e-this.entries[this.head].id;if(t<this.size)return this.entries[(this.head+t)%this.capacity]}},CircularBuffer.prototype.get_head=function(e){return this.size>0?this.entries[this.head]:void 0};var Outgoing=function(){this.deliveries=new CircularBuffer(2048),this.updated=[],this.next_delivery_id=0,this.next_pending_delivery=0,this.next_transfer_id=0,this.window=types.MAX_UINT,this.remote_next_transfer_id=void 0,this.remote_window=void 0};Outgoing.prototype.available=function(){return this.deliveries.available()},Outgoing.prototype.send=function(e,t,i,o){var n={id:this.next_delivery_id++,tag:t,link:e,data:i,format:o?o:0,sent:!1,settled:!1,state:void 0,remote_settled:!1,remote_state:void 0};return this.deliveries.push(n),n},Outgoing.prototype.on_begin=function(e){this.remo
 te_window=e.incoming_window},Outgoing.prototype.on_flow=function(e){this.remote_next_transfer_id=e.next_incoming_id,this.remote_window=e.incoming_window},Outgoing.prototype.on_disposition=function(e){for(var t=e.last?e.last:e.first,i=e.first;t>=i;i++){var o=this.deliveries.by_id(i);if(o||console.log("Could not find delivery for "+i+" ["+JSON.stringify(e)+"]"),o&&!o.remote_settled){var n=!1;e.settled&&(o.remote_settled=e.settled,n=!0),e.state&&e.state!==o.remote_state&&(o.remote_state=e.state,n=!0),n&&this.updated.push(o)}}},Outgoing.prototype.transfer_window=function(){return this.remote_window?this.remote_window-(this.next_transfer_id-this.remote_next_transfer_id):void 0},Outgoing.prototype.process=function(){for(;this.next_pending_delivery<this.next_delivery_id;){var e=this.deliveries.by_id(this.next_pending_delivery);if(!e){console.log("ERROR: Next pending delivery not found: "+this.next_pending_delivery);break}if(!e.link.has_credit()){log.flow("Link has no credit");break}if(e.li
 nk.delivery_count++,e.transfers_required=1,!(this.transfer_window()>=e.transfers_required)){log.flow("Incoming window of peer preventing sending further transfers: remote_window="+this.remote_window+", remote_next_transfer_id="+this.remote_next_transfer_id+", next_transfer_id="+this.next_transfer_id);break}this.next_transfer_id+=e.transfers_required,this.window-=e.transfers_required,e.link.session.output(frames.transfer({handle:e.link.local.handle,message_format:e.format,delivery_id:e.id,delivery_tag:e.tag}).described(),e.data),e.link.credit--,this.next_pending_delivery++}for(var t=0;t<this.updated.length;t++){var e=this.updated[t];e.remote_state&&(e.remote_state=message.unwrap_outcome(e.remote_state),e.remote_state&&e.remote_state.constructor.composite_type&&e.link.dispatch(e.remote_state.constructor.composite_type,e.link._context({delivery:e}))),e.remote_settled&&e.link.dispatch("settled",e.link._context({delivery:e}))}this.updated=[],this.deliveries.pop_if(function(e){return e.se
 ttled&&e.remote_settled})};var Incoming=function(){this.deliveries=new CircularBuffer(2048),this.updated=[],this.next_transfer_id=0,this.next_delivery_id=void 0,this.window=2048,this.remote_next_transfer_id=void 0,this.remote_window=void 0};Incoming.prototype.update=function(e,t,i){e&&(e.settled=t,void 0!==i&&(e.state=i),e.remote_settled||this.updated.push(e),e.link.connection._register())},Incoming.prototype.on_transfer=function(e,t){if(this.next_transfer_id++,t.is_open()){void 0===this.next_delivery_id&&(this.next_delivery_id=e.performative.delivery_id);var i,o,n=this.deliveries.get_head();if(n&&n.incomplete){if(void 0!==e.performative.delivery_id&&this.next_delivery_id!=e.performative.delivery_id)throw Error("frame sequence error: delivery "+this.next_delivery_id+" not complete, got "+e.performative.delivery_id);i=n,o=Buffer.concat([i.data,e.payload],i.data.size()+e.payload.size())}else{if(this.next_delivery_id!==e.performative.delivery_id)throw Error("frame sequence error: expec
 ted "+this.next_delivery_id+", got "+e.performative.delivery_id);i={id:e.performative.delivery_id,tag:e.performative.delivery_tag,link:t,settled:!1,state:void 0,remote_settled:e.performative.settled,remote_state:void 0};var s=this;i.update=function(e,t){s.update(i,e,t)},this.deliveries.push(i),o=e.payload}i.incomplete=e.performative.more,i.incomplete?i.data=o:(t.credit--,t.delivery_count++,this.next_delivery_id++,t.dispatch("message",t._context({message:message.decode(o),delivery:i})))}},Incoming.prototype.process=function(){if(this.updated.length>0){for(var e,t,i,o=0;o<this.updated.length;o++){var n=this.updated[o];void 0===e&&(e=n,t=n,i=n.id),message.are_outcomes_equivalent(t.state,n.state)&&t.settled===n.settled&&i===n.id?(t.id!==n.id&&(t=n),i++):(e.link.session.output(frames.disposition({role:!0,first:e.id,last:t.id,state:e.state,settled:e.settled}).described()),e=n,t=n,i=n.id)}void 0!==e&&void 0!==t&&e.link.session.output(frames.disposition({role:!0,first:e.id,last:t.id,state:e
 .state,settled:e.settled}).described()),this.updated=[]}this.deliveries.pop_if(function(e){return e.settled})},Incoming.prototype.on_begin=function(e){this.remote_window=e.outgoing_window},Incoming.prototype.on_flow=function(e){this.remote_next_transfer_id=e.next_outgoing_id,this.remote_window=e.outgoing_window},Incoming.prototype.on_disposition=function(e){for(var t=e.last?e.last:e.first,i=e.first;t>=i;i++){var o=this.deliveries.by_id(i);if(o||console.log("Could not find delivery for "+i),o&&!o.remote_settled){var n=!1;e.settled&&(o.remote_settled=e.settled,n=!0),e.state&&e.state!==o.remote_state&&(o.remote_state=e.state,n=!0),n&&(console.log(o.link.connection.options.id+" added delivery to updated list following receipt of disposition for incoming deliveries"),this.updated.push(o))}}};var Session=function(e,t){this.connection=e,this.outgoing=new Outgoing,this.incoming=new Incoming,this.state=new EndpointState,this.local={channel:t,handles:{}},this.local.begin=frames.begin({next_ou
 tgoing_id:this.outgoing.next_transfer_id,incoming_window:this.incoming.window,outgoing_window:this.outgoing.window}),this.local.end=frames.end(),this.remote={handles:{}},this.links={},this.options={}};Session.prototype=Object.create(EventEmitter.prototype),Session.prototype.constructor=Session,Session.prototype.reset=function(){this.state.disconnected(),this.outgoing=new Outgoing,this.incoming=new Incoming,this.remote={handles:{}};for(var e in this.links)this.links[e].reset()},Session.prototype.dispatch=function(e,t){log.events("Session got event: "+e),this.listeners(e).length?EventEmitter.prototype.emit.apply(this,arguments):this.connection.dispatch.apply(this.connection,arguments)},Session.prototype.output=function(e,t){this.connection._write_frame(this.local.channel,e,t)},Session.prototype.create_sender=function(e,t){return this.create_link(e,link.Sender,t)},Session.prototype.create_receiver=function(e,t){return this.create_link(e,link.Receiver,t)},Session.prototype.get_option=fu
 nction(e,t){return void 0!==this.options[e]?this.options[e]:this.connection.get_option(e,t)},Session.prototype.attach_sender=function(e){return attach(this.create_sender.bind(this),e,"target")},Session.prototype.open_sender=Session.prototype.attach_sender,Session.prototype.attach_receiver=function(e){return attach(this.create_receiver.bind(this),e,"source")},Session.prototype.open_receiver=Session.prototype.attach_receiver,Session.prototype.create_link=function(e,t,i){for(var o=0;this.local.handles[o];)o++;var n=new t(this,e,o,i);return this.links[e]=n,this.local.handles[o]=n,n},Session.prototype.begin=function(){this.state.open()&&this.connection._register()},Session.prototype.open=Session.prototype.begin,Session.prototype.end=function(){this.state.close()&&this.connection._register()},Session.prototype.close=Session.prototype.end,Session.prototype.is_open=function(){return this.connection.is_open()&&this.state.is_open()},Session.prototype.is_closed=function(){return this.connectio
 n.is_closed()||this.state.is_closed()},Session.prototype._process=function(){do{this.state.need_open()&&this.output(this.local.begin.described()),this.outgoing.process(),this.incoming.process();for(var e in this.links)this.links[e]._process();this.state.need_close()&&this.output(this.local.end.described())}while(!this.state.has_settled())},Session.prototype.send=function(e,t,i,o){var n=this.outgoing.send(e,t,i,o);return this.connection._register(),n},Session.prototype._write_flow=function(e){var t={next_incoming_id:this.incoming.next_transfer_id,incoming_window:this.incoming.window,next_outgoing_id:this.outgoing.next_transfer_id,outgoing_window:this.outgoing.window};e&&(t.delivery_count=e.delivery_count,t.handle=e.local.handle,t.link_credit=e.credit),this.output(frames.flow(t).described())},Session.prototype.on_begin=function(e){if(!this.state.remote_opened())throw Error("Begin already received");this.remote.channel||(this.remote.channel=e.channel),this.remote.begin=e.performative,t
 his.outgoing.on_begin(e.performative),this.incoming.on_begin(e.performative),this.open(),this.dispatch("session_open",this._context())},Session.prototype.on_end=function(e){if(!this.state.remote_closed())throw Error("End already received");this.remote.end=e.performative,this.close(),this.dispatch("session_close",this._context())},Session.prototype.on_attach=function(e){var t=e.performative.name,i=this.links[t];i||(i=e.performative.role?this.create_sender(t):this.create_receiver(t)),this.remote.handles[e.performative.handle]=i,i.on_attach(e),i.remote.attach=e.performative},Session.prototype.on_disposition=function(e){e.performative.role?(log.events("Received disposition for outgoing transfers"),this.outgoing.on_disposition(e.performative)):(log.events("Received disposition for incoming transfers"),this.incoming.on_disposition(e.performative)),this.connection._register()},Session.prototype.on_flow=function(e){this.outgoing.on_flow(e.performative),this.incoming.on_flow(e.performative),
 void 0!==e.performative.handle&&this._get_link(e).on_flow(e),this.connection._register()},Session.prototype._context=function(e){var t=e?e:{};return t.session=this,this.connection._context(t)},Session.prototype._get_link=function(e){var t=e.performative.handle,i=this.remote.handles[t];if(!i)throw Error("Invalid handle "+t);return i},Session.prototype.on_detach=function(e){this._get_link(e).on_detach(e);var t=e.performative.handle,i=this.remote.handles[t];delete this.remote.handles[t],delete this.local.handles[i.local.handle],delete this.links[i.name]},Session.prototype.on_transfer=function(e){this.incoming.on_transfer(e,this._get_link(e))},module.exports=Session;
+}).call(this,require("buffer").Buffer)
+
+},{"./endpoint.js":2,"./frames.js":3,"./link.js":4,"./log.js":5,"./message.js":6,"./types.js":12,"./util.js":13,"buffer":19,"events":23}],10:[function(require,module,exports){
+"use strict";function define_terminus(e){var t=types.define_composite(e);terminus[e.name]=t.create,by_descriptor[Number(t.descriptor.numeric).toString(10)]=t,by_descriptor[t.descriptor.symbolic]=t}var types=require("./types.js"),terminus={},by_descriptor={};terminus.unwrap=function(e){if(e&&e.descriptor){var t=by_descriptor[e.descriptor.value];if(t)return new t(e.value);console.log("Unknown terminus: "+e.descriptor)}return null},define_terminus({name:"source",code:40,fields:[{name:"address",type:"string"},{name:"durable",type:"uint",default_value:0},{name:"expiry_policy",type:"symbol",default_value:"session-end"},{name:"timeout",type:"uint",default_value:0},{name:"dynamic",type:"boolean",default_value:!1},{name:"dynamic_node_properties",type:"symbolic_map"},{name:"distribution_mode",type:"symbol"},{name:"filter",type:"symbolic_map"},{name:"default_outcome",type:"*"},{name:"outcomes",type:"symbol",multiple:!0},{name:"capabilities",type:"symbol",multiple:!0}]}),define_terminus({name:"
 target",code:41,fields:[{name:"address",type:"string"},{name:"durable",type:"uint",default_value:0},{name:"expiry_policy",type:"symbol",default_value:"session-end"},{name:"timeout",type:"uint",default_value:0},{name:"dynamic",type:"boolean",default_value:!1},{name:"dynamic_node_properties",type:"symbolic_map"},{name:"capabilities",type:"symbol",multiple:!0}]}),module.exports=terminus;
+},{"./types.js":12}],11:[function(require,module,exports){
+(function (Buffer){
+"use strict";var frames=require("./frames.js"),log=require("./log.js"),Transport=function(e,i,r,t){this.identifier=e,this.protocol_id=i,this.frame_type=r,this.handler=t,this.pending=[],this.header_sent=void 0,this.header_received=void 0,this.write_complete=!1,this.read_complete=!1};Transport.prototype.has_writes_pending=function(){return this.pending.length>0},Transport.prototype.encode=function(e){var i=frames.write_frame(e);log.frames("["+this.identifier+"] PENDING: "+JSON.stringify(e)),this.pending.push(i)},Transport.prototype.write=function(e){if(!this.header_sent){var i=new Buffer(8),r={protocol_id:this.protocol_id,major:1,minor:0,revision:0};frames.write_header(i,r),e.write(i),this.header_sent=r}for(var t=0;t<this.pending.length;t++)e.write(this.pending[t]),log.raw("["+this.identifier+"] SENT: "+JSON.stringify(this.pending[t]));this.pending=[]},Transport.prototype.read=function(e){var i=0;if(!this.header_received){if(e.length<8)return i;if(this.header_received=frames.read_head
 er(e),log.frames("["+this.identifier+"] RECV: "+JSON.stringify(this.header_received)),this.header_received.protocol_id!==this.protocol_id)throw Error("Invalid AMQP protocol id "+this.header_received.protocol_id+" expecting: "+this.protocol_id);i=8}for(;i<e.length&&!this.read_complete;){var r=e.readUInt32BE(i);if(log.io("["+this.identifier+"] got frame of size "+r),e.length<i+r){log.io("["+this.identifier+"] incomplete frame; have only "+(e.length-i)+" of "+r);break}var t=frames.read_frame(e.slice(i,i+r));if(log.frames("["+this.identifier+"] RECV: "+JSON.stringify(t)),t.type!==this.frame_type)throw Error("Invalid frame type: "+t.type);i+=r,t.performative&&t.performative.dispatch(this.handler,t)}return i},module.exports=Transport;
+}).call(this,require("buffer").Buffer)
+
+},{"./frames.js":3,"./log.js":5,"buffer":19}],12:[function(require,module,exports){
+(function (Buffer){
+"use strict";function Typed(t,e){this.type=t,this.value=e}function hex(t){return Number(t).toString(16)}function define_type(t,e,r,i){var n,o=e>>>4;switch(n=4===o?function(){this.type=n,this.value=i}:14===o||15===o?function(t,e,r){this.type=n,this.value=t,this.array_constructor={typecode:e},r&&(this.array_constructor.descriptor=r)}:function(t){this.type=n,this.value=t},n.typecode=e,n.prototype=Object.create(Typed.prototype),n.toString=function(){return t+"#"+hex(e)},o){case 4:n.width=0,n.category="fixed";break;case 5:n.width=1,n.category="fixed";break;case 6:n.width=2,n.category="fixed";break;case 7:n.width=4,n.category="fixed";break;case 8:n.width=8,n.category="fixed";break;case 9:n.width=16,n.category="fixed";break;case 10:n.width=1,n.category="variable";break;case 11:n.width=4,n.category="variable";break;case 12:n.width=1,n.category="compound";break;case 13:n.width=4,n.category="compound";break;case 14:n.width=1,n.category="array";break;case 15:n.width=4,n.category="array"}if(r)f
 or(var s in r)n[s]=r[s];return types.by_code[n.typecode]=n,types[t]=n,n}function buffer_ops(t){return{read:function(e,r){return e["read"+t](r)},write:function(e,r,i){e["write"+t](r,i)}}}function write_ulong(t,e,r){if("number"==typeof e||e instanceof Number){var i=e/MAX_UINT,n=e%MAX_UINT;t.writeUInt32BE(i,r),t.writeUInt32BE(n,r+4)}else e.copy(t,r)}function read_ulong(t,e){var r=t.readUInt32BE(e),i=t.readUInt32BE(e+4);return 2097153>r?r*MAX_UINT+i:t.slice(e,e+8)}function write_long(t,e,r){if("number"==typeof e||e instanceof Number){var i=Math.abs(e),n=i/MAX_UINT,o=i%MAX_UINT;if(t.writeInt32BE(n,r),t.writeUInt32BE(o,r+4),0>e)for(var s=1,p=0;8>p;p++){var a=r+(7-p),e=(255^t[a])+s;t[a]=255&e,s=e>>8}}else e.copy(t,r)}function read_long(t,e){var r=t.readInt32BE(e),i=t.readUInt32BE(e+4);return 2097153>r&&r>-2097153?r*MAX_UINT+i:t.slice(e,e+8)}function is_one_of(t,e){for(var r=0;r<e.length;r++)if(t.type.typecode===e[r].typecode)return!0;return!1}function mapify(t){for(var e={},r=0;r+1<t.lengt
 h;)e[t[r++]]=t[r++];return e}function get_type(t){var e=types.by_code[t];if(!e)throw Error("Unrecognised typecode: "+hex(t));return e}function max(t,e){return t>e?t:e}function get_constructor(t){if("symbol"===t)return{typecode:types.Sym8.typecode};throw Error("TODO: Array of type "+t+" not yet supported")}function wrap_field(t,e){if(void 0!==e&&null!==e){if(Array.isArray(e)){if(!t.multiple)throw Error("Field "+t.name+" does not support multiple values, got "+JSON.stringify(e));var r=get_constructor(t.type);return types.wrap_array(e,r.typecode,r.descriptor)}if("*"===t.type)return e;var i=types["wrap_"+t.type];if(i)return i(e);throw Error("No wrapper for field "+t.name+" of type "+t.type)}if(t.mandatory)throw Error("Field "+t.name+" is mandatory");return new types.Null}function get_accessors(t,e){var r=function(){return"*"===e.type?this.value[t]:types.unwrap(this.value[t])},i=function(r){this.value[t]=wrap_field(e,r)};return{get:r,set:i,enumerable:!0,configurable:!1}}function add_type
 (t){var e=types.define_composite(t);types["wrap_"+t.name]=function(t){return e.create(t).described()},by_descriptor[Number(e.descriptor.numeric).toString(10)]=e,by_descriptor[e.descriptor.symbolic]=e}Typed.prototype.toString=function(){return this.value?this.value.toString():null},Typed.prototype.toLocaleString=function(){return this.value?this.value.toLocaleString():null},Typed.prototype.valueOf=function(){return this.value},Typed.prototype.toJSON=function(){return this.value&&this.value.toJSON?this.value.toJSON():this.value};var types={by_code:{}};Object.defineProperty(types,"MAX_UINT",{value:4294967295,writable:!1,configurable:!1}),Object.defineProperty(types,"MAX_USHORT",{value:65535,writable:!1,configurable:!1});var MAX_UINT=4294967296;define_type("Null",64,void 0,null),define_type("Boolean",86,buffer_ops("UInt8")),define_type("True",65,void 0,!0),define_type("False",66,void 0,!1),define_type("Ubyte",80,buffer_ops("UInt8")),define_type("Ushort",96,buffer_ops("UInt16BE")),define
 _type("Uint",112,buffer_ops("UInt32BE")),define_type("SmallUint",82,buffer_ops("UInt8")),define_type("Uint0",67,void 0,0),define_type("Ulong",128,{write:write_ulong,read:read_ulong}),define_type("SmallUlong",83,buffer_ops("UInt8")),define_type("Ulong0",68,void 0,0),define_type("Byte",81,buffer_ops("Int8")),define_type("Short",97,buffer_ops("Int16BE")),define_type("Int",113,buffer_ops("Int32BE")),define_type("SmallInt",84,buffer_ops("Int8")),define_type("Long",129,{write:write_long,read:read_long}),define_type("SmallLong",85,buffer_ops("Int8")),define_type("Float",114,buffer_ops("Float")),define_type("Double",130,buffer_ops("Double")),define_type("Decimal32",116),define_type("Decimal64",132),define_type("Decimal128",148),define_type("CharUTF32",115),define_type("Timestamp",131),define_type("Uuid",152),define_type("Vbin8",160),define_type("Vbin32",176),define_type("Str8",161,{encoding:"utf8"}),define_type("Str32",177,{encoding:"utf8"}),define_type("Sym8",163,{encoding:"ascii"}),define
 _type("Sym32",179,{encoding:"ascii"}),define_type("List0",69,void 0,[]),define_type("List8",192),define_type("List32",208),define_type("Map8",193),define_type("Map32",209),define_type("Array8",224),define_type("Array32",240),types.is_ulong=function(t){return is_one_of(t,[types.Ulong,types.Ulong0,types.SmallUlong])},types.is_string=function(t){return is_one_of(t,[types.Str8,types.Str32])},types.is_symbol=function(t){return is_one_of(t,[types.Sym8,types.Sym32])},types.is_list=function(t){return is_one_of(t,[types.List0,types.List8,types.List32])},types.is_map=function(t){return is_one_of(t,[types.Map8,types.Map32])},types.wrap_boolean=function(t){return new types.Boolean(t)},types.wrap_ulong=function(t){return 0===t?new types.Ulong0:t>255?new types.Ulong(t):new types.SmallUlong(t)},types.wrap_uint=function(t){return 0===t?new types.Uint0:t>255?new types.Uint(t):new types.SmallUint(t)},types.wrap_ushort=function(t){return new types.Ushort(t)},types.wrap_ubyte=function(t){return new typ
 es.Ubyte(t)},types.wrap_long=function(t){return t>127||-128>t?new types.Long(t):new types.SmallLong(t)},types.wrap_int=function(t){return t>127||-128>t?new types.Int(t):new types.SmallInt(t)},types.wrap_short=function(t){return new types.Short(t)},types.wrap_byte=function(t){return new types.Byte(t)},types.wrap_float=function(t){return new types.Float(t)},types.wrap_double=function(t){return new types.Double(t)},types.wrap_timestamp=function(t){return new types.Timestamp(t)},types.wrap_binary=function(t){return t.length>255?new types.Vbin32(t):new types.Vbin8(t)},types.wrap_string=function(t){return t.length>255?new types.Str32(t):new types.Str8(t)},types.wrap_symbol=function(t){return t.length>255?new types.Sym32(t):new types.Sym8(t)},types.wrap_list=function(t){if(0===t.length)return new types.List0;var e=t.map(types.wrap);return new types.List32(e)},types.wrap_map=function(t,e){var r=[];for(var i in t)r.push(e?e(i):types.wrap(i)),r.push(types.wrap(t[i]));return new types.Map32(r)
 },types.wrap_symbolic_map=function(t){return types.wrap_map(t,types.wrap_symbol)},types.wrap_array=function(t,e,r){if(e)return new types.Array32(t,e,r);throw Error("An array must specify a type for its elements")},types.wrap=function(t){var e=typeof t;if("string"===e)return types.wrap_string(t);if("boolean"==e)return t?new types.True:new types.False;if("number"==e||t instanceof Number){if(isNaN(t))throw Error("Cannot wrap NaN! "+t);return Math.floor(t)-t!==0?new types.Double(t):t>0?types.wrap_uint(t):types.wrap_int(t)}return t instanceof Date?void 0:t instanceof Typed?t:"undefined"==e||null===t?new types.Null:Array.isArray(t)?types.wrap_list(t):types.wrap_map(t)},types.wrap_described=function(t,e){var r=types.wrap(t);return e&&("string"==typeof e?r=types.described(types.wrap_string(e),r):("number"==typeof e||e instanceof Number)&&(r=types.described(types.wrap_ulong(e),r))),r},types.wrap_message_id=function(t){var e=typeof t;if("string"===e)return types.wrap_string(t);if("number"==e|
 |t instanceof Number)return types.wrap_ulong(t);throw Error("invalid message id:"+t)},types.wrap_delivery_state=function(t){return new Null};var by_descriptor={};types.unwrap=function(t,e){if(t instanceof Typed){if(t.descriptor){var r=by_descriptor[t.descriptor.value];if(r)return new r(t.value);if(e)return t}var i=types.unwrap(t.value,!0);return types.is_map(t)?mapify(i):i}return Array.isArray(t)?t.map(function(t){return types.unwrap(t,!0)}):t},types.described=function(t,e){var r=Object.create(e);return t.length?(r.descriptor=t.shift(),described(t,r)):(r.descriptor=t,r)},types.Reader=function(t){this.buffer=t,this.position=0},types.Reader.prototype.read_typecode=function(){return this.read_uint(1)},types.Reader.prototype.read_uint=function(t){var e=this.position;this.position+=t;var r=t>1?"readUInt"+8*t+"BE":"readUInt8";return this.buffer[r](e)},types.Reader.prototype.read_fixed_width=function(t){var e=this.position;return this.position+=t.width,t.read?t.read(this.buffer,e):this.buf
 fer.slice(e,this.position)},types.Reader.prototype.read_variable_width=function(t){var e=this.read_uint(t.width),r=this.read_bytes(e);return t.encoding?r.toString(t.encoding):r},types.Reader.prototype.read=function(){var t=this.read_constructor(),e=this.read_value(get_type(t.typecode));return t.descriptor?types.described(t.descriptor,e):e},types.Reader.prototype.read_constructor=function(){var t=this.read_typecode();if(0===t){var e=[];e.push(this.read());for(var r=this.read_constructor();r.descriptor;)e.push(r.descriptor),r=this.read_constructor();return{typecode:r.typecode,descriptor:1==e.length?e[0]:e}}return{typecode:t}},types.Reader.prototype.read_value=function(t){if(0===t.width)return new t;if("fixed"===t.category)return new t(this.read_fixed_width(t));if("variable"===t.category)return new t(this.read_variable_width(t));if("compound"===t.category)return this.read_compound(t);if("array"===t.category)return this.read_array(t);throw Error("Invalid category for type: "+t)},types.R
 eader.prototype.read_multiple=function(t,e){for(var r=e?e:this.read.bind(this),i=[];i.length<t;)i.push(r.apply(this));return i},types.Reader.prototype.read_size_count=function(t){return{size:this.read_uint(t),count:this.read_uint(t)}},types.Reader.prototype.read_compound=function(t){var e=this.read_size_count(t.width);return new t(this.read_multiple(e.count))},types.Reader.prototype.read_array=function(t){var e=this.read_size_count(t.width),r=this.read_constructor(),i=new t(this.read_multiple(e.count,this.read_value.bind(this,get_type(r.typecode))),r.typecode,r.descriptor);return i},types.Reader.prototype.toString=function(){var t="buffer@"+this.position;this.position&&(t+=": ");for(var e=this.position;e<this.buffer.length;e++)e>0&&(t+=","),t+="0x"+Number(this.buffer[e]).toString(16);return t},types.Reader.prototype.reset=function(){this.position=0},types.Reader.prototype.skip=function(t){this.position+=t},types.Reader.prototype.read_bytes=function(t){var e=this.position;return this
 .position+=t,this.buffer.slice(e,this.position)},types.Reader.prototype.remaining=function(){return this.buffer.length-this.position},types.Writer=function(t){this.buffer=t?t:new Buffer(1024),this.position=0},types.Writer.prototype.toBuffer=function(){return this.buffer.slice(0,this.position)},types.Writer.prototype.ensure=function(t){if(this.buffer.length<t){var e=new Buffer(max(2*this.buffer.length,t));this.buffer.copy(e),this.buffer=e}},types.Writer.prototype.write_typecode=function(t){this.write_uint(t,1)},types.Writer.prototype.write_uint=function(t,e){var r=this.position;this.ensure(this.position+e),this.position+=e;var i=e>1?"writeUInt"+8*e+"BE":"writeUInt8";if(!this.buffer[i])throw Error("Buffer doesn't define "+i);return this.buffer[i](t,r)},types.Writer.prototype.write_fixed_width=function(t,e){var r=this.position;if(this.ensure(this.position+t.width),this.position+=t.width,t.write)t.write(this.buffer,e,r);else{if(!e.copy)throw Error("Can't handle write for "+t);e.copy(thi
 s.buffer,r)}},types.Writer.prototype.write_variable_width=function(t,e){var r=t.encoding?new Buffer(e,t.encoding):new Buffer(e);this.write_uint(r.length,t.width),this.write_bytes(r)},types.Writer.prototype.write_bytes=function(t){var e=this.position;this.ensure(this.position+t.length),this.position+=t.length,t.copy(this.buffer,e)},types.Writer.prototype.write_constructor=function(t,e){e&&(this.write_typecode(0),this.write(e)),this.write_typecode(t)},types.Writer.prototype.write=function(t){if(!(t instanceof Typed))throw Error("Can't write "+JSON.stringify(t));this.write_constructor(t.type.typecode,t.descriptor),this.write_value(t.type,t.value,t.array_constructor)},types.Writer.prototype.write_value=function(t,e,r){if(0!==t.width)if("fixed"===t.category)this.write_fixed_width(t,e);else if("variable"===t.category)this.write_variable_width(t,e);else if("compound"===t.category)this.write_compound(t,e);else{if("array"!==t.category)throw Error("Invalid category "+t.category+" for type: "+
 t);this.write_array(t,e,r)}},types.Writer.prototype.backfill_size=function(t,e){var r=this.position-e;this.position=e,this.write_uint(r-t,t),this.position+=r-t},types.Writer.prototype.write_compound=function(t,e){var r=this.position;this.position+=t.width,this.write_uint(e.length,t.width);for(var i=0;i<e.length;i++)void 0===e[i]||null===e[i]?this.write(new types.Null):this.write(e[i]);this.backfill_size(t.width,r)},types.Writer.prototype.write_array=function(t,e,r){var i=this.position;this.position+=t.width,this.write_uint(e.length,t.width),this.write_constructor(r.typecode,r.descriptor);for(var t=get_type(r.typecode),n=0;n<e.length;n++)this.write_value(t,e[n]);this.backfill_size(t.width,i)},types.Writer.prototype.toString=function(){var t="buffer@"+this.position;this.position&&(t+=": ");for(var e=0;e<this.position;e++)e>0&&(t+=","),t+=("00"+Number(this.buffer[e]).toString(16)).slice(-2);return t},types.Writer.prototype.skip=function(t){this.ensure(this.position+t),this.position+=t}
 ,types.Writer.prototype.clear=function(){this.buffer.fill(0),this.position=0},types.Writer.prototype.remaining=function(){return this.buffer.length-this.position},types.define_composite=function(t){var e=function(t){this.value=t?t:[]};e.descriptor={numeric:t.code,symbolic:"amqp:"+t.name+":list"},e.prototype.dispatch=function(e,r){e["on_"+t.name](r)};for(var r=0;r<t.fields.length;r++){var i=t.fields[r];Object.defineProperty(e.prototype,i.name,get_accessors(r,i))}return e.toString=function(){return t.name+"#"+Number(t.code).toString(16)},e.prototype.toJSON=function(){var t={};for(var e in this)"value"!==e&&this[e]&&(t[e]=this[e]);return t},e.create=function(t){var r=new e;for(var i in t)r[i]=t[i];return r},e.prototype.described=function(t){return types.described(types.wrap_ulong(e.descriptor.numeric),types.wrap_list(this.value))},e},add_type({name:"error",code:29,fields:[{name:"condition",type:"symbol",mandatory:!0},{name:"description",type:"string"},{name:"info",type:"map"}]}),module
 .exports=types;
+}).call(this,require("buffer").Buffer)
+
+},{"buffer":19}],13:[function(require,module,exports){
+"use strict";var util={};util.generate_uuid=function(){var x="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(x){var t=16*Math.random()|0,r="x"==x?t:3&t|8;return r.toString(16)});return x},util.clone=function(x){for(var t=Object.create(x.prototype||{}),r=Object.getOwnPropertyNames(x),e=0;e<r.length;e++){var n=r[e];t[n]=x[n]}return t},module.exports=util;
+},{}],14:[function(require,module,exports){
+(function (Buffer){
+"use strict";function nulltransform(n){return n}function from_arraybuffer(n){return n instanceof ArrayBuffer?new Buffer(new Uint8Array(n)):new Buffer(n)}function to_typedarray(n){return new Uint8Array(n)}function wrap(n){var r=nulltransform,e=nulltransform;return n.binaryType&&(n.binaryType="arraybuffer",r=from_arraybuffer,e=to_typedarray),{end:function(){n.close()},write:function(r){n.send(e(r),{binary:!0})},on:function(e,t){"data"===e?n.onmessage=function(n){t(r(n.data))}:"end"===e?n.onclose=t:"error"===e?n.onerror=t:console.log("ERROR: Attempt to set unrecognised handler on websocket wrapper: "+e)},get_id_string:function(){return n.url}}}module.exports={connect:function(n){return function(r,e){return function(){return{connect:function(t,o,u,a){var f=new n(r,e);return f.onopen=a,wrap(f)}}}}},wrap:wrap};
+}).call(this,require("buffer").Buffer)
+
+},{"buffer":19}],15:[function(require,module,exports){
+function useColors(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function formatArgs(){var o=arguments,e=this.useColors;if(o[0]=(e?"%c":"")+this.namespace+(e?" %c":" ")+o[0]+(e?"%c ":" ")+"+"+exports.humanize(this.diff),!e)return o;var r="color: "+this.color;o=[o[0],r,"color: inherit"].concat(Array.prototype.slice.call(o,1));var t=0,s=0;return o[0].replace(/%[a-z%]/g,function(o){"%%"!==o&&(t++,"%c"===o&&(s=t))}),o.splice(s,0,r),o}function log(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function save(o){try{null==o?exports.storage.removeItem("debug"):exports.storage.debug=o}catch(e){}}function load(){var o;try{o=exports.storage.debug}catch(e){}return o}function localstorage(){try{return window.localStorage}catch(o){}}exports=module.exports=require("./deb
 ug"),exports.log=log,exports.formatArgs=formatArgs,exports.save=save,exports.load=load,exports.useColors=useColors,exports.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:localstorage(),exports.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],exports.formatters.j=function(o){return JSON.stringify(o)},exports.enable(load());
+},{"./debug":16}],16:[function(require,module,exports){
+function selectColor(){return exports.colors[prevColor++%exports.colors.length]}function debug(e){function r(){}function o(){var e=o,r=+new Date,s=r-(prevTime||r);e.diff=s,e.prev=prevTime,e.curr=r,prevTime=r,null==e.useColors&&(e.useColors=exports.useColors()),null==e.color&&e.useColors&&(e.color=selectColor());var t=Array.prototype.slice.call(arguments);t[0]=exports.coerce(t[0]),"string"!=typeof t[0]&&(t=["%o"].concat(t));var n=0;t[0]=t[0].replace(/%([a-z%])/g,function(r,o){if("%%"===r)return r;n++;var s=exports.formatters[o];if("function"==typeof s){var p=t[n];r=s.call(e,p),t.splice(n,1),n--}return r}),"function"==typeof exports.formatArgs&&(t=exports.formatArgs.apply(e,t));var p=o.log||exports.log||console.log.bind(console);p.apply(e,t)}r.enabled=!1,o.enabled=!0;var s=exports.enabled(e)?o:r;return s.namespace=e,s}function enable(e){exports.save(e);for(var r=(e||"").split(/[\s,]+/),o=r.length,s=0;o>s;s++)r[s]&&(e=r[s].replace(/\*/g,".*?"),"-"===e[0]?exports.skips.push(new RegExp("
 ^"+e.substr(1)+"$")):exports.names.push(new RegExp("^"+e+"$")))}function disable(){exports.enable("")}function enabled(e){var r,o;for(r=0,o=exports.skips.length;o>r;r++)if(exports.skips[r].test(e))return!1;for(r=0,o=exports.names.length;o>r;r++)if(exports.names[r].test(e))return!0;return!1}function coerce(e){return e instanceof Error?e.stack||e.message:e}exports=module.exports=debug,exports.coerce=coerce,exports.disable=disable,exports.enable=enable,exports.enabled=enabled,exports.humanize=require("ms"),exports.names=[],exports.skips=[],exports.formatters={};var prevColor=0,prevTime;
+},{"ms":17}],17:[function(require,module,exports){
+function parse(e){if(e=""+e,!(e.length>1e4)){var a=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(a){var r=parseFloat(a[1]),c=(a[2]||"ms").toLowerCase();switch(c){case"years":case"year":case"yrs":case"yr":case"y":return r*y;case"days":case"day":case"d":return r*d;case"hours":case"hour":case"hrs":case"hr":case"h":return r*h;case"minutes":case"minute":case"mins":case"min":case"m":return r*m;case"seconds":case"second":case"secs":case"sec":case"s":return r*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}}}function short(e){return e>=d?Math.round(e/d)+"d":e>=h?Math.round(e/h)+"h":e>=m?Math.round(e/m)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function long(e){return plural(e,d,"day")||plural(e,h,"hour")||plural(e,m,"minute")||plural(e,s,"second")||e+" ms"}function plural(s,e,a){return e>s?void 0:1.5*e>s?Math.floor(s/e)+" "+a:Math.ceil(s/e)+" "+a+"s"}var s=1e3,m=60*s,h=60*m,d=24*h
 ,y=365.25*d;module.exports=function(s,e){return e=e||{},"string"==typeof s?parse(s):e["long"]?long(s):short(s)};
+},{}],18:[function(require,module,exports){
+
+},{}],19:[function(require,module,exports){
+(function (global){
+"use strict";function typedArraySupport(){try{var t=new Uint8Array(1);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Buffer(t){return this instanceof Buffer?(Buffer.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?fromNumber(this,t):"string"==typeof t?fromString(this,t,arguments.length>1?arguments[1]:"utf8"):fromObject(this,t)):arguments.length>1?new Buffer(t,arguments[1]):new Buffer(t)}function fromNumber(t,e){if(t=allocate(t,0>e?0:0|checked(e)),!Buffer.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;r++)t[r]=0;return t}function fromString(t,e,r){("string"!=typeof r||""===r)&&(r="utf8");var n=0|byteLength(e,r);return t=allocate(t,n),t.write(e,r),t}function fromObject(t,e){if(Buffer.isBuffer(e))return fromBuffer(t,e);if(isArray(e))return fromArray(t,e);if(null==e)throw new TypeError("must start with nu
 mber, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(e.buffer instanceof ArrayBuffer)return fromTypedArray(t,e);if(e instanceof ArrayBuffer)return fromArrayBuffer(t,e)}return e.length?fromArrayLike(t,e):fromJsonObject(t,e)}function fromBuffer(t,e){var r=0|checked(e.length);return t=allocate(t,r),e.copy(t,0,0,r),t}function fromArray(t,e){var r=0|checked(e.length);t=allocate(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function fromTypedArray(t,e){var r=0|checked(e.length);t=allocate(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function fromArrayBuffer(t,e){return e.byteLength,Buffer.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=Buffer.prototype):t=fromTypedArray(t,new Uint8Array(e)),t}function fromArrayLike(t,e){var r=0|checked(e.length);t=allocate(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function fromJsonObject(t,e){var r,n=0;"Buffer"===e.type&&isArray(e.data)&&(r=e.data,n=0|checked(r.length)),t=allocate(t,n);for(var f=0;n>f;f+=1)t[f]=255&r[f
 ];return t}function allocate(t,e){Buffer.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=Buffer.prototype):t.length=e;var r=0!==e&&e<=Buffer.poolSize>>>1;return r&&(t.parent=rootParent),t}function checked(t){if(t>=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|t}function SlowBuffer(t,e){if(!(this instanceof SlowBuffer))return new SlowBuffer(t,e);var r=new Buffer(t,e);return delete r.parent,r}function byteLength(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return utf8ToBytes(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(t).length;default:if(n)return utf8ToBytes(t).length;e=(""+e).toLowerCase(),n=!0}}function slowToString(t,e,r){var n=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t|
 |(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return hexSlice(this,e,r);case"utf8":case"utf-8":return utf8Slice(this,e,r);case"ascii":return asciiSlice(this,e,r);case"binary":return binarySlice(this,e,r);case"base64":return base64Slice(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function hexWrite(t,e,r,n){r=Number(r)||0;var f=t.length-r;n?(n=Number(n),n>f&&(n=f)):n=f;var i=e.length;if(i%2!==0)throw new Error("Invalid hex string");n>i/2&&(n=i/2);for(var o=0;n>o;o++){var u=parseInt(e.substr(2*o,2),16);if(isNaN(u))throw new Error("Invalid hex string");t[r+o]=u}return o}function utf8Write(t,e,r,n){return blitBuffer(utf8ToBytes(e,t.length-r),t,r,n)}function asciiWrite(t,e,r,n){return blitBuffer(asciiToBytes(e),t,r,n)}function binaryWrite(t,e,r,n){return asciiWrite(t,e,r,n)}function base64Write(t,e,r,n){retur
 n blitBuffer(base64ToBytes(e),t,r,n)}function ucs2Write(t,e,r,n){return blitBuffer(utf16leToBytes(e,t.length-r),t,r,n)}function base64Slice(t,e,r){return 0===e&&r===t.length?base64.fromByteArray(t):base64.fromByteArray(t.slice(e,r))}function utf8Slice(t,e,r){r=Math.min(t.length,r);for(var n=[],f=e;r>f;){var i=t[f],o=null,u=i>239?4:i>223?3:i>191?2:1;if(r>=f+u){var s,h,a,c;switch(u){case 1:128>i&&(o=i);break;case 2:s=t[f+1],128===(192&s)&&(c=(31&i)<<6|63&s,c>127&&(o=c));break;case 3:s=t[f+1],h=t[f+2],128===(192&s)&&128===(192&h)&&(c=(15&i)<<12|(63&s)<<6|63&h,c>2047&&(55296>c||c>57343)&&(o=c));break;case 4:s=t[f+1],h=t[f+2],a=t[f+3],128===(192&s)&&128===(192&h)&&128===(192&a)&&(c=(15&i)<<18|(63&s)<<12|(63&h)<<6|63&a,c>65535&&1114112>c&&(o=c))}}null===o?(o=65533,u=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),f+=u}return decodeCodePointsArray(n)}function decodeCodePointsArray(t){var e=t.length;if(MAX_ARGUMENTS_LENGTH>=e)return String.fromCharCode.apply(String
 ,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=MAX_ARGUMENTS_LENGTH));return r}function asciiSlice(t,e,r){var n="";r=Math.min(t.length,r);for(var f=e;r>f;f++)n+=String.fromCharCode(127&t[f]);return n}function binarySlice(t,e,r){var n="";r=Math.min(t.length,r);for(var f=e;r>f;f++)n+=String.fromCharCode(t[f]);return n}function hexSlice(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var f="",i=e;r>i;i++)f+=toHex(t[i]);return f}function utf16leSlice(t,e,r){for(var n=t.slice(e,r),f="",i=0;i<n.length;i+=2)f+=String.fromCharCode(n[i]+256*n[i+1]);return f}function checkOffset(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function checkInt(t,e,r,n,f,i){if(!Buffer.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>f||i>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range")}function ob
 jectWriteUInt16(t,e,r,n){0>e&&(e=65535+e+1);for(var f=0,i=Math.min(t.length-r,2);i>f;f++)t[r+f]=(e&255<<8*(n?f:1-f))>>>8*(n?f:1-f)}function objectWriteUInt32(t,e,r,n){0>e&&(e=4294967295+e+1);for(var f=0,i=Math.min(t.length-r,4);i>f;f++)t[r+f]=e>>>8*(n?f:3-f)&255}function checkIEEE754(t,e,r,n,f,i){if(e>f||i>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function writeFloat(t,e,r,n,f){return f||checkIEEE754(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(t,e,r,n,23,4),r+4}function writeDouble(t,e,r,n,f){return f||checkIEEE754(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(t,e,r,n,52,8),r+8}function base64clean(t){if(t=stringtrim(t).replace(INVALID_BASE64_RE,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function stringtrim(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function toHex(t){return 16>t?"0"+t.toString(
 16):t.toString(16)}function utf8ToBytes(t,e){e=e||1/0;for(var r,n=t.length,f=null,i=[],o=0;n>o;o++){if(r=t.charCodeAt(o),r>55295&&57344>r){if(!f){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&i.push(239,191,189);continue}f=r;continue}if(56320>r){(e-=3)>-1&&i.push(239,191,189),f=r;continue}r=(f-55296<<10|r-56320)+65536}else f&&(e-=3)>-1&&i.push(239,191,189);if(f=null,128>r){if((e-=1)<0)break;i.push(r)}else if(2048>r){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function asciiToBytes(t){for(var e=[],r=0;r<t.length;r++)e.push(255&t.charCodeAt(r));return e}function utf16leToBytes(t,e){for(var r,n,f,i=[],o=0;o<t.length&&!((e-=2)<0);o++)r=t.charCodeAt(o),n=r>>8,f=r%256,i.push(f),i.push(n);return i}function base64ToBytes(t){return base64.toByteArray(bas
 e64clean(t))}function blitBuffer(t,e,r,n){for(var f=0;n>f&&!(f+r>=e.length||f>=t.length);f++)e[f+r]=t[f];return f}var base64=require("base64-js"),ieee754=require("ieee754"),isArray=require("isarray");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50,Buffer.poolSize=8192;var rootParent={};Buffer.TYPED_ARRAY_SUPPORT=void 0!==global.TYPED_ARRAY_SUPPORT?global.TYPED_ARRAY_SUPPORT:typedArraySupport(),Buffer.TYPED_ARRAY_SUPPORT?(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array):(Buffer.prototype.length=void 0,Buffer.prototype.parent=void 0),Buffer.isBuffer=function(t){return!(null==t||!t._isBuffer)},Buffer.compare=function(t,e){if(!Buffer.isBuffer(t)||!Buffer.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,f=0,i=Math.min(r,n);i>f&&t[f]===e[f];)++f;return f!==i&&(r=t[f],n=e[f]),n>r?-1:r>n?1:0},Buffer.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf
 8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(t,e){if(!isArray(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new Buffer(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;r++)e+=t[r].length;var n=new Buffer(e),f=0;for(r=0;r<t.length;r++){var i=t[r];i.copy(n,f),f+=i.length}return n},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?utf8Slice(this,0,t):slowToString.apply(this,arguments)},Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",e=exports.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t
 +">"},Buffer.prototype.compare=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:Buffer.compare(this,t)},Buffer.prototype.indexOf=function(t,e){function r(t,e,r){for(var n=-1,f=0;r+f<t.length;f++)if(t[r+f]===e[-1===n?0:f-n]){if(-1===n&&(n=f),f-n+1===e.length)return r+n}else n=-1;return-1}if(e>2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(Buffer.isBuffer(t))return r(this,t,e);if("number"==typeof t)return Buffer.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):r(this,[t],e);throw new TypeError("val must be string, number or Buffer")},Buffer.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite
 (e))e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var f=n;n=e,e=0|r,r=f}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return hexWrite(this,t,e,r);case"utf8":case"utf-8":return utf8Write(this,t,e,r);case"ascii":return asciiWrite(this,t,e,r);case"binary":return binaryWrite(this,t,e,r);case"base64":return base64Write(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var n;if(Buffer.TYPED_ARRAY_SU
 PPORT)n=this.subarray(t,e),n.__proto__=Buffer.prototype;else{var f=e-t;n=new Buffer(f,void 0);for(var i=0;f>i;i++)n[i]=this[i+t]}return n.length&&(n.parent=this.parent||this),n},Buffer.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||checkOffset(t,e,this.length);for(var n=this[t],f=1,i=0;++i<e&&(f*=256);)n+=this[t+i]*f;return n},Buffer.prototype.readUIntBE=function(t,e,r){t=0|t,e=0|e,r||checkOffset(t,e,this.length);for(var n=this[t+--e],f=1;e>0&&(f*=256);)n+=this[t+--e]*f;return n},Buffer.prototype.readUInt8=function(t,e){return e||checkOffset(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return e||checkOffset(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return e||checkOffset(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return e||checkOffset(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return e||checkOffset(t,
 4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||checkOffset(t,e,this.length);for(var n=this[t],f=1,i=0;++i<e&&(f*=256);)n+=this[t+i]*f;return f*=128,n>=f&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||checkOffset(t,e,this.length);for(var n=e,f=1,i=this[t+--n];n>0&&(f*=256);)i+=this[t+--n]*f;return f*=128,i>=f&&(i-=Math.pow(2,8*e)),i},Buffer.prototype.readInt8=function(t,e){return e||checkOffset(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,e){e||checkOffset(t,2,this.length);var r=this[t]|this[t+1]<<8;ret

<TRUNCATED>

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[3/6] qpid-dispatch git commit: using minified rhea library

Posted by ea...@apache.org.
using minified rhea library


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/f9ba97fd
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/f9ba97fd
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/f9ba97fd

Branch: refs/heads/master
Commit: f9ba97fdbd3a5b73e0af46502cad1c6c7c6597bb
Parents: 9d0bed0
Author: Ernest Allen <ea...@redhat.com>
Authored: Mon Feb 22 12:13:15 2016 -0500
Committer: Ernest Allen <ea...@redhat.com>
Committed: Mon Feb 22 12:13:15 2016 -0500

----------------------------------------------------------------------
 console/stand-alone/index.html             |  2 +-
 console/stand-alone/plugin/lib/rhea-min.js | 93 +++++++++++++++++++++++++
 2 files changed, 94 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/f9ba97fd/console/stand-alone/index.html
----------------------------------------------------------------------
diff --git a/console/stand-alone/index.html b/console/stand-alone/index.html
index 63bf162..f719a04 100644
--- a/console/stand-alone/index.html
+++ b/console/stand-alone/index.html
@@ -113,7 +113,7 @@ under the License.
     <script type="text/javascript" src="plugin/js/qdrTopology.js"></script>
     <script type="text/javascript" src="plugin/js/qdrSettings.js"></script>
 
-    <script type="text/javascript" src="plugin/lib/rhea.js"></script>
+    <script type="text/javascript" src="plugin/lib/rhea-min.js"></script>
 
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.fancytree/2.15.0/jquery.fancytree.js" type="text/javascript"></script>
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[4/6] qpid-dispatch git commit: removed rhea.js and use rhea-min.js

Posted by ea...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/f60fd9f6/console/stand-alone/plugin/lib/rhea.js
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/lib/rhea.js b/console/stand-alone/plugin/lib/rhea.js
deleted file mode 100644
index fa323a3..0000000
--- a/console/stand-alone/plugin/lib/rhea.js
+++ /dev/null
@@ -1,7716 +0,0 @@
-require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
-(function (process,Buffer){
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-'use strict';
-
-var frames = require('./frames.js');
-var log = require('./log.js');
-var sasl = require('./sasl.js');
-var types = require('./types.js');
-var util = require('./util.js');
-var EndpointState = require('./endpoint.js');
-var Session = require('./session.js');
-var Transport = require('./transport.js');
-
-var net = require("net");
-var tls = require("tls");
-var EventEmitter = require('events').EventEmitter;
-
-var AMQP_PROTOCOL_ID = 0x00;
-var TLS_PROTOCOL_ID = 0x02;
-
-function get_socket_id(socket) {
-    if (socket.get_id_string) return socket.get_id_string();
-    return socket.localAddress + ':' + socket.localPort + ' -> ' + socket.remoteAddress + ':' + socket.remotePort;
-};
-
-function session_per_connection(conn) {
-    var ssn = null;
-    return {
-        'get_session' : function () {
-            if (!ssn) {
-                ssn = conn.create_session();
-                ssn.begin();
-            }
-            return ssn;
-        }
-    };
-};
-
-function restrict(count, f) {
-    if (count) {
-        var current = count;
-        var reset;
-        return function (successful_attempts) {
-            if (reset !== successful_attempts) {
-                current = count;
-                reset = successful_attempts;
-            }
-            if (current--) return f(successful_attempts);
-            else return -1;
-        };
-    } else {
-        return f;
-    }
-}
-
-function backoff(initial, max) {
-    var delay = initial;
-    var reset;
-    return function (successful_attempts) {
-        if (reset !== successful_attempts) {
-            delay = initial;
-            reset = successful_attempts;
-        }
-        var current = delay;
-        var next = delay*2;
-        delay = max > next ? next : max;
-        return current;
-    };
-}
-
-function get_connect_fn(options) {
-    if (options.transport === undefined || options.transport === 'tcp') {
-        return net.connect;
-    } else if (options.transport === 'tls' || options.transport === 'ssl') {
-        return tls.connect;
-    } else {
-        throw Error('Unrecognised transport: ' + options.transport);
-    }
-}
-
-function connection_details(options) {
-    var details = {};
-    details.connect = options.connect ? options.connect : get_connect_fn(options);
-    details.host = options.host ? options.host : 'localhost';
-    details.port = options.port ? options.port : 5672;
-    details.options = options;
-    return details;
-};
-
-var conn_counter = 1;
-
-var Connection = function (options, container) {
-    this.options = {};
-    if (options) {
-        for (var k in options) {
-            this.options[k] = options[k];
-        }
-    }
-    this.container = container;
-    if (!this.options.id) {
-        this.options.id = 'connection-' + conn_counter++;
-    }
-    if (!this.options.container_id) {
-        this.options.container_id = container ? container.id : util.generate_uuid();
-    }
-    if (!this.options.connection_details) {
-        var self = this;
-        this.options.connection_details = function() { return connection_details(self.options); };
-    }
-    var reconnect = this.get_option('reconnect', true);
-    if (typeof reconnect === 'boolean' && reconnect) {
-        var initial = this.get_option('initial_reconnect_delay', 100);
-        var max = this.get_option('max_reconnect_delay', 60000);
-        this.options.reconnect = restrict(this.get_option('reconnect_limit'), backoff(initial, max));
-    } else if (typeof reconnect === 'number') {
-        var fixed = this.options.reconnect
-        this.options.reconnect = restrict(this.get_option('reconnect_limit'), function () { return fixed; });
-    }
-    this.registered = false;
-    this.state = new EndpointState();
-    this.local_channel_map = {};
-    this.remote_channel_map = {};
-    this.local = {};
-    this.remote = {};
-    this.local.open = frames.open(this.options);
-    this.local.close = frames.close({});
-    this.session_policy = session_per_connection(this);
-    this.amqp_transport = new Transport(this.options.id, AMQP_PROTOCOL_ID, frames.TYPE_AMQP, this);
-    this.sasl_transport = undefined;
-    this.transport = this.amqp_transport;
-    this.conn_established_counter = 0;
-    this.heartbeat_out = undefined;
-    this.heartbeat_in = undefined;
-    this.abort_idle = false;
-    this.socket_ready = false;
-};
-
-Connection.prototype = Object.create(EventEmitter.prototype);
-Connection.prototype.constructor = Connection;
-Connection.prototype.dispatch = function(name, context) {
-    log.events('Connection got event: ' + name);
-    if (this.listeners(name).length) {
-        EventEmitter.prototype.emit.apply(this, arguments);
-        return true;
-    } else if (this.container) {
-        return this.container.dispatch.apply(this.container, arguments);
-    }
-};
-
-Connection.prototype.reset = function() {
-    if (this.abort_idle) {
-        this.abort_idle = false;
-        this.local.close.error = undefined;
-        this.state = new EndpointState();
-        this.state.open();
-    }
-
-    //reset transport
-    this.amqp_transport = new Transport(this.options.id, AMQP_PROTOCOL_ID, frames.TYPE_AMQP, this);
-    this.sasl_transport = undefined;
-    this.transport = this.amqp_transport;
-
-    //reset remote endpoint state
-    this.state.disconnected();
-    this.remote = {};
-    //reset sessions:
-    this.remote_channel_map = {};
-    for (var k in this.local_channel_map) {
-        this.local_channel_map[k].reset();
-    }
-    this.socket_ready = false;
-}
-
-Connection.prototype.connect = function () {
-    this.is_server = false;
-    this._connect(this.options.connection_details(this.conn_established_counter));
-    this.open();
-    return this;
-};
-Connection.prototype.reconnect = function () {
-    log.reconnect('reconnecting...');
-    this.reset();
-    this._connect(this.options.connection_details(this.conn_established_counter));
-    process.nextTick(this._process.bind(this));
-    return this;
-};
-
-Connection.prototype._connect = function (details) {
-    if (details.connect) {
-        this.init(details.connect(details.port, details.host, details.options, this.connected.bind(this)));
-    } else {
-        this.init(get_connect_fn(details)(details.port, details.host, details.options, this.connected.bind(this)));
-    }
-    return this;
-};
-
-Connection.prototype.accept = function (socket) {
-    this.is_server = true;
-    log.io('[' + this.id + '] client accepted: '+ get_socket_id(socket));
-    this.socket_ready = true;
-    return this.init(socket);
-};
-
-Connection.prototype.init = function (socket) {
-    this.socket = socket;
-    this.socket.on('data', this.input.bind(this));
-    this.socket.on('error', this.error.bind(this));
-    this.socket.on('end', this.eof.bind(this));
-
-    if (this.is_server) {
-        var mechs;
-        if (this.container && Object.getOwnPropertyNames(this.container.sasl_server_mechanisms).length) {
-            mechs = this.container.sasl_server_mechanisms;
-        }
-        if (this.socket.encrypted && this.socket.authorized && this.get_option('enable_sasl_external', false)) {
-            mechs = sasl.server_add_external(mechs ? util.clone(mechs) : {});
-        }
-        if (mechs) {
-            this.sasl_transport = new sasl.Server(this, mechs);
-        }
-    } else {
-        var mechanisms = this.get_option('sasl_mechanisms');
-        if (!mechanisms) {
-            var username = this.get_option('username');
-            var password = this.get_option('password');
-            if (username) {
-                mechanisms = sasl.client_mechanisms();
-                if (password) mechanisms.enable_plain(username, password);
-                else mechanisms.enable_anonymous(username);
-            }
-        }
-        if (this.socket.encrypted && this.options.cert && this.get_option('enable_sasl_external', false)) {
-            if (!mechanisms) mechanisms = sasl.client_mechanisms();
-            mechanisms.enable_external();
-        }
-
-        if (mechanisms) {
-            this.sasl_transport = new sasl.Client(this, mechanisms);
-        }
-    }
-    this.transport = this.sasl_transport ? this.sasl_transport : this.amqp_transport;
-    return this;
-};
-
-Connection.prototype.attach_sender = function (options) {
-    return this.session_policy.get_session().attach_sender(options);
-};
-Connection.prototype.open_sender = Connection.prototype.attach_sender;//alias
-
-Connection.prototype.attach_receiver = function (options) {
-    return this.session_policy.get_session().attach_receiver(options);
-};
-Connection.prototype.open_receiver = Connection.prototype.attach_receiver;//alias
-
-Connection.prototype.get_option = function (name, default_value) {
-    if (this.options[name] !== undefined) return this.options[name];
-    else if (this.container) return this.container.get_option(name, default_value);
-    else return default_value;
-};
-
-Connection.prototype.connected = function () {
-    this.socket_ready = true;
-    this.conn_established_counter++;
-    log.io('[' + this.options.id + '] connected ' + get_socket_id(this.socket));
-    this.output();
-};
-Connection.prototype.sasl_failed = function (text) {
-    this.transport_error = {condition:'amqp:unauthorized-access', description:text};
-    this._handle_error();
-}
-
-Connection.prototype._handle_error = function () {
-    var error = this.get_error();
-    if (error) {
-        //TODO: invoke connection_close regardless of whether connection_error is handled
-        //TODO: example for error handling
-        if (!this.dispatch('connection_error', this._context())) {
-            if (!this.dispatch('connection_close', this._context())) {
-                console.log('error: ' + JSON.stringify(error));
-            }
-        }
-        return true;
-    } else {
-        return false;
-    }
-}
-
-Connection.prototype.get_error = function () {
-    if (this.transport_error) return this.transport_error;
-    if (this.remote.close && this.remote.close.error) return this.remote.close.error;
-    return undefined;
-}
-
-Connection.prototype.output = function () {
-    if (this.socket && this.socket_ready) {
-        if (this.heartbeat_out) clearTimeout(this.heartbeat_out);
-        this.transport.write(this.socket);
-        if (((this.is_closed() && this.state.has_settled()) || this.abort_idle || this.transport_error) && !this.transport.has_writes_pending()) {
-            this.socket.end();
-        } else if (this.is_open() && this.remote.open.idle_time_out) {
-            this.heartbeat_out = setTimeout(this._write_frame.bind(this), this.remote.open.idle_time_out / 2);
-        }
-    }
-};
-
-Connection.prototype.input = function (buff) {
-    if (this.heartbeat_in) clearTimeout(this.heartbeat_in);
-    log.io('[' + this.options.id + '] read ' + buff.length + ' bytes');
-    var buffer;
-    if (this.previous_input) {
-        buffer = Buffer.concat([this.previous_input, buff], this.previous_input.length + buff.length);
-        this.previous_input = null;
-    } else {
-        buffer = buff;
-    }
-    var read = this.transport.read(buffer, this);
-    if (read < buffer.length) {
-        this.previous_input = buffer.slice(read);
-    }
-    if (this.local.open.idle_time_out) this.heartbeat_in = setTimeout(this.idle.bind(this), this.local.open.idle_time_out);
-    if (this.transport.has_writes_pending()) this.output();
-};
-
-Connection.prototype.idle = function () {
-    if (this.is_open()) {
-        this.abort_idle = true;
-        this.local.close.error = {condition:'amqp:resource-limit-exceeded', description:'max idle time exceeded'};
-        this.close();
-    }
-};
-
-Connection.prototype.error = function (e) {
-    console.log('[' + this.options.id + '] error: ' + e);
-    this._disconnected();
-};
-
-Connection.prototype.eof = function (e) {
-    this._disconnected();
-};
-
-Connection.prototype._disconnected = function () {
-    if (!this.is_closed()) {
-        if (!this.dispatch('disconnected', this._context())) {
-            console.log('[' + this.options.id + '] disconnected');
-        }
-        if (!this.is_server && !this.transport_error && this.options.reconnect) {
-            var delay = this.options.reconnect(this.conn_established_counter);
-            if (delay >= 0) {
-                log.reconnect('Scheduled reconnect in ' + delay + 'ms');
-                setTimeout(this.reconnect.bind(this), delay);
-            }
-        }
-    }
-};
-
-Connection.prototype.open = function () {
-    if (this.state.open()) {
-        this._register();
-    }
-};
-Connection.prototype.close = function () {
-    if (this.state.close()) {
-        this._register();
-    }
-};
-
-Connection.prototype.is_open = function () {
-    return this.state.is_open();
-};
-
-Connection.prototype.is_closed = function () {
-    return this.state.is_closed();
-};
-
-Connection.prototype.create_session = function () {
-    var i = 0;
-    while (this.local_channel_map[i]) i++;
-    var session = new Session(this, i);
-    this.local_channel_map[i] = session;
-    return session;
-}
-
-Connection.prototype.on_open = function (frame) {
-    if (this.state.remote_opened()) {
-        this.remote.open = frame.performative;
-        this.open();
-        this.dispatch('connection_open', this._context());
-    } else {
-        throw Error('Open already received');
-    }
-};
-
-Connection.prototype.on_close = function (frame) {
-    if (this.state.remote_closed()) {
-        this.remote.close = frame.performative;
-        this.close();
-        if (this.remote.close.error) {
-            this._handle_error();
-        } else {
-            this.dispatch('connection_close', this._context());
-        }
-        if (this.heartbeat_out) clearTimeout(this.heartbeat_out);
-    } else {
-        throw Error('Close already received');
-    }
-};
-
-Connection.prototype._register = function () {
-    if (!this.registered) {
-        this.registered = true;
-        process.nextTick(this._process.bind(this));
-    }
-};
-
-Connection.prototype._process = function () {
-    this.registered = false;
-    do {
-        if (this.state.need_open()) {
-            this._write_open();
-        }
-        for (var k in this.local_channel_map) {
-            this.local_channel_map[k]._process();
-        }
-        if (this.state.need_close()) {
-            this._write_close();
-        }
-    } while (!this.state.has_settled());
-};
-
-Connection.prototype._write_frame = function (channel, frame, payload) {
-    this.amqp_transport.encode(frames.amqp_frame(channel, frame, payload));
-    this.output();
-};
-
-Connection.prototype._write_open = function () {
-    this._write_frame(0, this.local.open.described());
-};
-
-Connection.prototype._write_close = function () {
-    this._write_frame(0, this.local.close.described());
-};
-
-Connection.prototype.on_begin = function (frame) {
-    var session;
-    if (frame.performative.remote_channel === null || frame.performative.remote_channel === undefined) {
-        //peer initiated
-        session = this.create_session();
-        session.local.begin.remote_channel = frame.channel;
-    } else {
-        session = this.local_channel_map[frame.performative.remote_channel];
-        if (!session) throw Error('Invalid value for remote channel ' + frame.performative.remote_channel);
-    }
-    session.on_begin(frame);
-    this.remote_channel_map[frame.channel] = session;
-};
-
-Connection.prototype.get_peer_certificate = function() {
-    if (this.socket && this.socket.getPeerCertificate) {
-        return this.socket.getPeerCertificate();
-    } else {
-        return undefined;
-    }
-};
-
-Connection.prototype._context = function (c) {
-    var context = c ? c : {};
-    context.connection = this;
-    if (this.container) context.container = this.container;
-    return context;
-};
-
-function delegate_to_session(name) {
-    Connection.prototype['on_' + name] = function (frame) {
-        var session = this.remote_channel_map[frame.channel];
-        if (!session) {
-            throw Error(name + ' received on invalid channel ' + frame.channel);
-        }
-        session['on_' + name](frame);
-    };
-};
-
-delegate_to_session('end');
-delegate_to_session('attach');
-delegate_to_session('detach');
-delegate_to_session('transfer');
-delegate_to_session('disposition');
-delegate_to_session('flow');
-
-module.exports = Connection
-
-}).call(this,require('_process'),require("buffer").Buffer)
-},{"./endpoint.js":2,"./frames.js":3,"./log.js":5,"./sasl.js":8,"./session.js":9,"./transport.js":11,"./types.js":12,"./util.js":13,"_process":24,"buffer":19,"events":23,"net":18,"tls":18}],2:[function(require,module,exports){
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-'use strict';
-
-var EndpointState = function () {
-    this.init();
-};
-
-EndpointState.prototype.init = function () {
-    this.local_open = false;
-    this.remote_open = false;
-    this.open_requests = 0;
-    this.close_requests = 0;
-    this.initialised = false;
-};
-
-EndpointState.prototype.open = function () {
-    this.initialised = true;
-    if (!this.local_open) {
-        this.local_open = true;
-        this.open_requests++;
-        return true;
-    } else {
-        return false;
-    }
-};
-
-EndpointState.prototype.close = function () {
-    if (this.local_open) {
-        this.local_open = false;
-        this.close_requests++;
-        return true;
-    } else {
-        return false;
-    }
-};
-
-EndpointState.prototype.disconnected = function () {
-    var was_open = this.local_open;
-    this.init();
-    if (was_open) {
-        this.open();
-    } else {
-        this.close();
-    }
-};
-
-EndpointState.prototype.remote_opened = function (frame) {
-    if (!this.remote_open) {
-        this.remote_open = true;
-        return true;
-    } else {
-        return false;
-    }
-};
-
-EndpointState.prototype.remote_closed = function (frame) {
-    if (this.remote_open) {
-        this.remote_open = false;
-        return true;
-    } else {
-        return false;
-    }
-};
-
-EndpointState.prototype.is_open = function () {
-    return this.local_open && this.remote_open;
-};
-
-EndpointState.prototype.is_closed = function () {
-    return this.initialised && !this.local_open && !this.remote_open;
-};
-
-EndpointState.prototype.has_settled = function () {
-    return this.open_requests == 0 && this.close_requests == 0;
-};
-
-EndpointState.prototype.need_open = function () {
-    if (this.open_requests > 0) {
-        this.open_requests--;
-        return true;
-    } else {
-        return false;
-    }
-};
-
-EndpointState.prototype.need_close = function () {
-    if (this.close_requests > 0) {
-        this.close_requests--;
-        return true;
-    } else {
-        return false;
-    }
-};
-
-module.exports = EndpointState
-
-},{}],3:[function(require,module,exports){
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-'use strict';
-
-var types = require('./types.js');
-
-var frames = {};
-var by_descriptor = {};
-
-frames.read_header = function(buffer) {
-    var offset = 4;
-    var header = {};
-    var name = buffer.toString('ascii', 0, offset);
-    if (name !== 'AMQP') {
-        throw Error('Invalid protocol header for AMQP ' + name);
-    }
-    header.protocol_id = buffer.readUInt8(offset++);
-    header.major = buffer.readUInt8(offset++);
-    header.minor = buffer.readUInt8(offset++);
-    header.revision = buffer.readUInt8(offset++);
-    if (header.major !== 1 || header.minor !== 0) {
-        throw Error('Unsupported AMQP version: ' + JSON.stringify(header));
-    }
-    return header;
-};
-frames.write_header = function(buffer, header) {
-    var offset = 4;
-    buffer.write('AMQP', 0, offset, 'ascii');
-    buffer.writeUInt8(header.protocol_id, offset++);
-    buffer.writeUInt8(header.major, offset++);
-    buffer.writeUInt8(header.minor, offset++);
-    buffer.writeUInt8(header.revision, offset++);
-    return 8;
-};
-//todo: define enumeration for frame types
-frames.TYPE_AMQP = 0x00;
-frames.TYPE_SASL = 0x01;
-
-frames.read_frame = function(buffer) {
-    var reader = new types.Reader(buffer);
-    var frame = {};
-    frame.size = reader.read_uint(4);
-    if (reader.remaining < frame.size) {
-        return null;
-    }
-    var doff = reader.read_uint(1);
-    if (doff < 2) {
-        throw Error('Invalid data offset, must be at least 2 was ' + doff);
-    }
-    frame.type = reader.read_uint(1);
-    if (frame.type === frames.TYPE_AMQP) {
-        frame.channel = reader.read_uint(2);
-    } else if (frame.type === frames.TYPE_SASL) {
-        reader.skip(2);
-    } else {
-        throw Error('Unknown frame type ' + frame.type);
-    }
-    if (doff > 1) {
-        //ignore any extended header
-        reader.skip(doff * 4 - 8);
-    }
-    if (reader.remaining()) {
-        frame.performative = reader.read();
-        var c = by_descriptor[frame.performative.descriptor.value];
-        if (c) {
-            frame.performative = new c(frame.performative.value);
-        }
-        if (reader.remaining()) {
-            frame.payload = reader.read_bytes(reader.remaining());
-        }
-    }
-    return frame;
-};
-
-frames.write_frame = function(frame) {
-    var writer = new types.Writer();
-    writer.skip(4);//skip size until we know how much we have written
-    writer.write_uint(2, 1);//doff
-    writer.write_uint(frame.type, 1);
-    if (frame.type === frames.TYPE_AMQP) {
-        writer.write_uint(frame.channel, 2);
-    } else if (frame.type === frames.TYPE_SASL) {
-        writer.write_uint(0, 2);
-    } else {
-        throw Error('Unknown frame type ' + frame.type);
-    }
-    if (frame.performative) {
-        writer.write(frame.performative);
-        if (frame.payload) {
-            writer.write_bytes(frame.payload);
-        }
-    }
-    var buffer = writer.toBuffer();
-    buffer.writeUInt32BE(buffer.length, 0);//fill in the size
-    return buffer;
-};
-
-frames.amqp_frame = function(channel, performative, payload) {
-    return {'channel': channel || 0, 'type': frames.TYPE_AMQP, 'performative': performative, 'payload': payload};
-};
-frames.sasl_frame = function(performative) {
-    return {'channel': 0, 'type': frames.TYPE_SASL, 'performative': performative};
-};
-
-function define_frame(type, def) {
-    var c = types.define_composite(def);
-    frames[def.name] = c.create;
-    by_descriptor[Number(c.descriptor.numeric).toString(10)] = c;
-    by_descriptor[c.descriptor.symbolic] = c;
-};
-
-var open = {name: "open",
-            code: 0x10,
-            fields: [
-                 {name:"container_id", type:"string", mandatory:true},
-                 {name:"hostname", type:"string"},
-                 {name:"max_frame_size", type:"uint", default_value:4294967295},
-                 {name:"channel_max", type:"ushort", default_value:65535},
-                 {name:"idle_time_out", type:"uint"},
-                 {name:"outgoing_locales", type:"symbol", multiple:true},
-                 {name:"incoming_locales", type:"symbol", multiple:true},
-                 {name:"offered_capabilities", type:"symbol", multiple:true},
-                 {name:"desired_capabilities", type:"symbol", multiple:true},
-                 {name:"properties", type:"symbolic_map"}
-             ]
-           };
-
-var begin = {name:"begin",
-             code:0x11,
-             fields:[
-                 {name:"remote_channel", type:"ushort"},
-                 {name:"next_outgoing_id", type:"uint", mandatory:true},
-                 {name:"incoming_window", type:"uint", mandatory:true},
-                 {name:"outgoing_window", type:"uint", mandatory:true},
-                 {name:"handle_max", type:"uint", default_value:"4294967295"},
-                 {name:"offered_capabilities", type:"symbol", multiple:true},
-                 {name:"desired_capabilities", type:"symbol", multiple:true},
-                 {name:"properties", type:"symbolic_map"}
-             ]
-            };
-
-var attach = {name:"attach",
-              code:0x12,
-              fields:[
-                  {name:"name", type:"string", mandatory:true},
-                  {name:"handle", type:"uint", mandatory:true},
-                  {name:"role", type:"boolean", mandatory:true},
-                  {name:"snd_settle_mode", type:"ubyte", default_value:2},
-                  {name:"rcv_settle_mode", type:"ubyte", default_value:0},
-                  {name:"source", type:"*"},
-                  {name:"target", type:"*"},
-                  {name:"unsettled", type:"map"},
-                  {name:"incomplete_unsettled", type:"boolean", default_value:false},
-                  {name:"initial_delivery_count", type:"uint"},
-                  {name:"max_message_size", type:"ulong"},
-                  {name:"offered_capabilities", type:"symbol", multiple:true},
-                  {name:"desired_capabilities", type:"symbol", multiple:true},
-                  {name:"properties", type:"symbolic_map"}
-              ]
-             };
-
-var flow = {name:"flow",
-            code:0x13,
-            fields:[
-                {name:"next_incoming_id", type:"uint"},
-                {name:"incoming_window", type:"uint", mandatory:true},
-                {name:"next_outgoing_id", type:"uint", mandatory:true},
-                {name:"outgoing_window", type:"uint", mandatory:true},
-                {name:"handle", type:"uint"},
-                {name:"delivery_count", type:"uint"},
-                {name:"link_credit", type:"uint"},
-                {name:"available", type:"uint"},
-                {name:"drain", type:"boolean", default_value:false},
-                {name:"echo", type:"boolean", default_value:false},
-                {name:"properties", type:"symbolic_map"}
-            ]
-           };
-
-var transfer = {name:"transfer",
-                code:0x14,
-                fields:[
-                    {name:"handle", type:"uint", mandatory:true},
-                    {name:"delivery_id", type:"uint"},
-                    {name:"delivery_tag", type:"binary"},
-                    {name:"message_format", type:"uint"},
-                    {name:"settled", type:"boolean"},
-                    {name:"more", type:"boolean", default_value:false},
-                    {name:"rcv_settle_mode", type:"ubyte"},
-                    {name:"state", type:"delivery_state"},
-                    {name:"resume", type:"boolean", default_value:false},
-                    {name:"aborted", type:"boolean", default_value:false},
-                    {name:"batchable", type:"boolean", default_value:false}
-                ]
-               };
-
-var disposition = {name:"disposition",
-                   code:0x15,
-                   fields:[
-                       {name:"role", type:"boolean", mandatory:true},
-                       {name:"first", type:"uint", mandatory:true},
-                       {name:"last", type:"uint"},
-                       {name:"settled", type:"boolean", default_value:false},
-                       {name:"state", type:"*"},
-                       {name:"batchable", type:"boolean", default_value:false}
-                   ]
-                  };
-
-var detach = {name: "detach",
-             code: 0x16,
-              fields: [
-                  {name:"handle", type:"uint", mandatory:true},
-                  {name:"closed", type:"boolean", default_value:false},
-                  {name:"error", type:"error"}
-              ]
-             };
-
-var end = {name: "end",
-             code: 0x17,
-             fields: [
-                 {name:"error", type:"error"}
-             ]
-            };
-
-var close = {name: "close",
-             code: 0x18,
-             fields: [
-                 {name:"error", type:"error"}
-             ]
-            };
-
-define_frame(frames.TYPE_AMQP, open);
-define_frame(frames.TYPE_AMQP, begin);
-define_frame(frames.TYPE_AMQP, attach);
-define_frame(frames.TYPE_AMQP, flow);
-define_frame(frames.TYPE_AMQP, transfer);
-define_frame(frames.TYPE_AMQP, disposition);
-define_frame(frames.TYPE_AMQP, detach);
-define_frame(frames.TYPE_AMQP, end);
-define_frame(frames.TYPE_AMQP, close);
-
-var sasl_mechanisms = {name:"sasl_mechanisms", code:0x40,
-                       fields: [
-                           {name:"sasl_server_mechanisms", type:"symbol", multiple:true, mandatory:true}
-                       ]};
-
-var sasl_init = {name:"sasl_init", code:0x41,
-                 fields: [
-                     {name:"mechanism", type:"symbol", mandatory:true},
-                     {name:"initial_response", type:"binary"},
-                     {name:"hostname", type:"string"}
-                 ]};
-
-var sasl_challenge = {name:"sasl_challenge", code:0x42,
-                      fields: [
-                          {name:"challenge", type:"binary", mandatory:true}
-                      ]};
-
-var sasl_response = {name:"sasl_response", code:0x43,
-                     fields: [
-                         {name:"response", type:"binary", mandatory:true}
-                     ]};
-
-var sasl_outcome = {name:"sasl_outcome", code:0x44,
-                    fields: [
-                        {name:"code", type:"ubyte", mandatory:true},
-                        {name:"additional_data", type:"binary"}
-                    ]};
-
-define_frame(frames.TYPE_SASL, sasl_mechanisms);
-define_frame(frames.TYPE_SASL, sasl_init);
-define_frame(frames.TYPE_SASL, sasl_challenge);
-define_frame(frames.TYPE_SASL, sasl_response);
-define_frame(frames.TYPE_SASL, sasl_outcome);
-
-module.exports = frames;
-
-},{"./types.js":12}],4:[function(require,module,exports){
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-'use strict';
-
-var frames = require('./frames.js');
-var log = require('./log.js');
-var message = require('./message.js');
-var terminus = require('./terminus.js')
-var types = require('./types.js')
-var EndpointState = require('./endpoint.js');
-
-var FlowController = function (window) {
-    this.window = window;
-};
-FlowController.prototype.update = function (context) {
-    var delta = this.window - context.receiver.credit;
-    context.receiver.flow(delta);
-};
-
-function auto_settle(context) {
-    context.delivery.settled = true;
-};
-
-function auto_accept(context) {
-    context.delivery.update(true, message.accepted().described());
-};
-
-var EventEmitter = require('events').EventEmitter;
-
-var link = Object.create(EventEmitter.prototype);
-link.dispatch = function(name, context) {
-    log.events('Link got event: '+ name);
-    EventEmitter.prototype.emit.apply(this.observers, arguments);
-    if (this.listeners(name).length) {
-        EventEmitter.prototype.emit.apply(this, arguments);
-    } else {
-        this.session.dispatch.apply(this.session, arguments);
-    }
-};
-link.set_source = function (fields) {
-    this.local.attach.source = terminus.source(fields).described();
-};
-link.set_target = function (fields) {
-    this.local.attach.target = terminus.target(fields).described();
-};
-
-link.attach = function () {
-    if (this.state.open()) {
-        this.connection._register();
-    }
-};
-link.open = link.attach;
-
-link.detach = function () {
-    this.local.detach.closed = false;
-    if (this.state.close()) {
-        this.connection._register();
-    }
-};
-link.close = function() {
-    this.local.detach.closed = true;
-    if (this.state.close()) {
-        this.connection._register();
-    }
-}
-
-link.is_open = function () {
-    return this.session.is_open() && this.state.is_open();
-};
-
-link.is_closed = function () {
-    return this.session.is_closed() || this.state.is_closed();
-};
-
-link._process = function () {
-    do {
-        if (this.state.need_open()) {
-            this.session.output(this.local.attach.described());
-        }
-
-        if (this.issue_flow) {
-            this.session._write_flow(this);
-            this.issue_flow = false;
-        }
-
-        if (this.state.need_close()) {
-            this.session.output(this.local.detach.described());
-        }
-    } while (!this.state.has_settled());
-};
-
-link.on_attach = function (frame) {
-    if (this.state.remote_opened()) {
-        if (!this.remote.handle) {
-            this.remote.handle = frame.handle;
-        }
-        frame.performative.source = terminus.unwrap(frame.performative.source);
-        frame.performative.target = terminus.unwrap(frame.performative.target);
-        this.remote.attach = frame.performative;
-        this.open();
-        this.dispatch(this.is_receiver() ? 'receiver_open' : 'sender_open', this._context());
-    } else {
-        throw Error('Attach already received');
-    }
-};
-
-link.on_detach = function (frame) {
-    if (this.state.remote_closed()) {
-        this.remote.detach = frame.performative;
-        this.close();
-        this.dispatch(this.local.attach.role ? 'receiver_close' : 'sender_close', this._context());
-    } else {
-        throw Error('Detach already received');
-    }
-};
-
-function is_internal(name) {
-    switch (name) {
-    case 'handle':
-    case 'role':
-    case 'initial_delivery_count':
-        return true;
-    default:
-        return false;
-    }
-}
-
-link.init = function (session, name, local_handle, opts, is_receiver) {
-    this.session = session;
-    this.connection = session.connection;
-    this.name = name;
-    this.options = opts === undefined ? {} : opts;
-    this.state = new EndpointState();
-    this.issue_flow = false;//currently only used by receiver
-    this.local = {'handle': local_handle};
-    this.local.attach = frames.attach({'handle':local_handle,'name':name, role:is_receiver});
-    for (var f in this.local.attach) {
-        if (!is_internal(f) && this.options[f] !== undefined) {
-            this.local.attach[f] = this.options[f];
-        }
-    }
-    this.local.detach = frames.detach({'handle':local_handle, 'closed':true});
-    this.remote = {'handle':undefined};
-    this.delivery_count = 0;
-    this.credit = 0;
-    this.observers = new EventEmitter();
-};
-link.reset = function() {
-    this.state.disconnected();
-    this.remote = {'handle':undefined};
-    this.delivery_count = 0;
-    this.credit = 0;
-};
-
-link.has_credit = function () {
-    return this.credit > 0;
-};
-link.is_receiver = function () {
-    return this.local.attach.role;
-};
-link._context = function (c) {
-    var context = c ? c : {};
-    if (this.is_receiver()) {
-        context.receiver = this;
-    } else {
-        context.sender = this;
-    }
-    return this.session._context(context);
-};
-link.get_option = function (name, default_value) {
-    if (this.options[name] !== undefined) return this.options[name];
-    else return this.session.get_option(name, default_value);
-};
-
-var Sender = function (session, name, local_handle, opts) {
-    this.init(session, name, local_handle, opts, false);
-    this.local.attach.initial_delivery_count = 0;
-    this.tag = 0;
-    if (this.get_option('autosettle', true)) {
-        this.observers.on('settled', auto_settle);
-    }
-};
-Sender.prototype = Object.create(link);
-Sender.prototype.constructor = Sender;
-Sender.prototype.next_tag = function () {
-    return new String(this.tag++);
-};
-Sender.prototype.sendable = function (frame) {
-    return this.credit && this.session.outgoing.available();
-}
-Sender.prototype.on_flow = function (frame) {
-    var flow = frame.performative;
-    this.credit = flow.delivery_count + flow.link_credit - this.delivery_count;
-    if (this.is_open()) {
-        this.dispatch('sender_flow', this._context());
-        if (this.sendable()) {
-            this.dispatch('sendable', this._context());
-        }
-    }
-};
-Sender.prototype.on_transfer = function (frame) {
-    throw Error('got transfer on sending link');
-};
-Sender.prototype.send = function (msg, tag) {
-    return this.session.send(this, tag ? tag : this.next_tag(), message.encode(msg), 0);
-};
-
-
-var Receiver = function (session, name, local_handle, opts) {
-    this.init(session, name, local_handle, opts, true);
-    this.set_prefetch(this.get_option('prefetch', 100));
-    if (this.get_option('autoaccept', true)) {
-        this.observers.on('message', auto_accept);
-    }
-};
-Receiver.prototype = Object.create(link);
-Receiver.prototype.constructor = Receiver;
-Receiver.prototype.on_flow = function (frame) {
-    this.dispatch('receiver_flow', this._context());
-};
-Receiver.prototype.flow = function(credit) {
-    if (credit > 0) {
-        this.credit += credit;
-        this.issue_flow = true;
-        this.connection._register();
-    }
-};
-
-Receiver.prototype.set_prefetch = function(prefetch) {
-    if (prefetch > 0) {
-        var flow_controller = new FlowController(prefetch);
-        var listener = flow_controller.update.bind(flow_controller);
-        this.observers.on('message', listener);
-        this.observers.on('receiver_open', listener);
-    }
-}
-
-module.exports = {'Sender': Sender, 'Receiver':Receiver};
-
-},{"./endpoint.js":2,"./frames.js":3,"./log.js":5,"./message.js":6,"./terminus.js":10,"./types.js":12,"events":23}],5:[function(require,module,exports){
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-'use strict';
-
-var debug = require('debug');
-
-module.exports = {
-    'frames' : debug('rhea:frames'),
-    'raw' : debug('rhea:raw'),
-    'reconnect' : debug('rhea:reconnect'),
-    'events' : debug('rhea:events'),
-    'message' : debug('rhea:message'),
-    'flow' : debug('rhea:flow'),
-    'io' : debug('rhea:io')
-}
-
-},{"debug":15}],6:[function(require,module,exports){
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-'use strict';
-
-var log = require('./log.js');
-var types = require('./types.js');
-
-var by_descriptor = {};
-var unwrappers = {};
-var wrappers = [];
-var message = {};
-
-function define_section(descriptor, unwrap, wrap) {
-    unwrap.descriptor = descriptor;
-    unwrappers[descriptor.symbolic] = unwrap;
-    unwrappers[Number(descriptor.numeric).toString(10)] = unwrap;
-    if (wrap) {
-        wrappers.push(wrap);
-    }
-};
-
-function define_composite_section(def) {
-    var c = types.define_composite(def);
-    message[def.name] = c.create;
-    by_descriptor[Number(c.descriptor.numeric).toString(10)] = c;
-    by_descriptor[c.descriptor.symbolic] = c;
-
-    var unwrap = function (msg, section) {
-        msg[def.name] = new c(section.value);
-    };
-
-    var wrap = function (sections, msg) {
-        if (msg[def.name]) {
-            if (msg[def.name].described) {
-                sections.push(msg[def.name].described());
-            } else {
-                sections.push(c.create(msg[def.name]).described());
-            }
-        }
-    };
-    define_section(c.descriptor, unwrap, wrap);
-};
-
-
-function define_map_section(def) {
-    var descriptor = {numeric:def.code};
-    descriptor.symbolic = 'amqp:' + def.name.replace(/_/g, '-') + ':map';
-    var unwrap = function (msg, section) {
-        msg[def.name] = types.unwrap(section);
-    };
-    var wrap = function (sections, msg) {
-        if (msg[def.name]) {
-            sections.push(types.described(types.wrap_ulong(descriptor.numeric), types.wrap_map(msg[def.name])));
-        }
-    };
-    define_section(descriptor, unwrap, wrap);
-};
-
-define_composite_section({name:"header",
-                          code:0x70,
-                          fields:[
-                              {name:"durable", type:"boolean", default_value:false},
-                              {name:"priority", type:"ubyte", default_value:4},
-                              {name:"ttl", type:"uint"},
-                              {name:"first_acquirer", type:"boolean", default_value:false},
-                              {name:"delivery_count", type:"uint", default_value:0}
-                          ]
-                         });
-define_map_section({name:"delivery_annotations", code:0x71});
-define_map_section({name:"message_annotations", code:0x72});
-define_composite_section({name:"properties",
-                          code:0x73,
-                          fields:[
-                              {name:"message_id", type:"message_id"},
-                              {name:"user_id", type:"binary"},
-                              {name:"to", type:"string"},
-                              {name:"subject", type:"string"},
-                              {name:"reply_to", type:"string"},
-                              {name:"correlation_id", type:"message_id"},
-                              {name:"content_type", type:"symbol"},
-                              {name:"content_encoding", type:"symbol"},
-                              {name:"absolute_expiry_time", type:"timestamp"},
-                              {name:"creation_time", type:"timestamp"},
-                              {name:"group_id", type:"string"},
-                              {name:"group_sequence", type:"uint"},
-                              {name:"reply_to_group_id", type:"string"}
-                          ]
-                         });
-define_map_section({name:"application_properties", code:0x74});
-
-define_section({numeric:0x77, symbolic:'amqp:value:*'},
-               function(msg, section) { msg.body = types.unwrap(section); },
-               function(sections, msg) { sections.push(types.described(types.wrap_ulong(0x77), types.wrap(msg.body))); });
-
-define_map_section({name:"footer", code:0x78});
-
-message.encode = function(obj) {
-    var sections = [];
-
-    wrappers.forEach(function (wrapper_fn) { wrapper_fn(sections, obj); });
-    var writer = new types.Writer();
-    for (var i = 0; i < sections.length; i++) {
-        log.message('Encoding section ' + (i+1) + ' of ' + sections.length + ': ' + sections[i]);
-        writer.write(sections[i]);
-    }
-    var data = writer.toBuffer();
-    log.message('encoded ' + data.length + ' bytes');
-    return data;
-}
-
-message.decode = function(buffer) {
-    var msg = {};
-    var reader = new types.Reader(buffer);
-    while (reader.remaining()) {
-        var s = reader.read();
-        log.message('decoding section: ' + JSON.stringify(s) + ' of type: ' + JSON.stringify(s.descriptor));
-        if (s.descriptor) {
-            var unwrap = unwrappers[s.descriptor.value];
-            if (unwrap) {
-                unwrap(msg, s);
-            } else {
-                console.log("WARNING: did not recognise message section with descriptor " + s.descriptor);
-            }
-        } else {
-            console.log("WARNING: expected described message section got " + JSON.stringify(s));
-        }
-    }
-    return msg;
-}
-
-var outcomes = {};
-
-function define_outcome(def) {
-    var c = types.define_composite(def);
-    c.composite_type = def.name;
-    message[def.name] = c.create;
-    outcomes[Number(c.descriptor.numeric).toString(10)] = c;
-    outcomes[c.descriptor.symbolic] = c;
-    message['is_' + def.name] = function (o) {
-        if (o && o.descriptor) {
-            var c = outcomes[o.descriptor.value];
-            if (c) {
-                return c.descriptor.numeric == def.code;
-            }
-        }
-        return false;
-    };
-}
-
-message.unwrap_outcome = function (outcome) {
-    if (outcome && outcome.descriptor) {
-        var c = outcomes[outcome.descriptor.value];
-        if (c) {
-            return new c(outcome);
-        }
-    }
-    console.log('unrecognised outcome');
-    return outcome;
-};
-
-message.are_outcomes_equivalent = function(a, b) {
-    if (a === undefined && b === undefined) return true;
-    else if (a === undefined || b === undefined) return false;
-    else return a.descriptor.value == b.descriptor.value && JSON.stringify(a) == JSON.stringify(b);
-};
-
-define_outcome({name:"received", code:0x23,
-                fields:[
-                    {name:"section-number", type:"uint", mandatory:true},
-                    {name:"section-offset", type:"ulong", mandatory:true}
-                ]});
-define_outcome({name:"accepted", code:0x24, fields:[]});
-define_outcome({name:"rejected", code:0x25, fields:[{name:"error", type:"error"}]});
-define_outcome({name:"released", code:0x26, fields:[]});
-define_outcome({name:"modified",
- code:0x27,
- fields:[
-     {name:"delivery-failed", type:"boolean"},
-     {name:"undeliverable-here", type:"boolean"},
-     {name:"message-annotations", type:"fields"}
-]});
-
-module.exports = message;
-
-},{"./log.js":5,"./types.js":12}],7:[function(require,module,exports){
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-'use strict';
-
-var url = require('url');
-
-var simple_id_generator = {
-    counter : 1,
-    next : function() {
-        return this.counter++;
-    }
-};
-
-var Client = function (container, address) {
-    var u = url.parse(address);
-    //TODO: handle scheme and user/password if present
-    this.connection = container.connect({'host':u.hostname, 'port':u.port});
-    this.connection.on('message', this._response.bind(this));
-    this.connection.on('receiver_open', this._ready.bind(this));
-    this.sender = this.connection.attach_sender(u.path.substr(1));
-    this.receiver = this.connection.attach_receiver({source:{dynamic:true}});
-    this.id_generator = simple_id_generator;
-    this.pending = [];//requests yet to be made (waiting for receiver to open)
-    this.outstanding = {};//requests sent, for which responses have not yet been received
-};
-
-Client.prototype._request = function (id, name, args, callback) {
-    var request = {properties:{}};
-    request.properties.subject = name;
-    request.body = args;
-    request.properties.message_id = id;
-    request.properties.reply_to = this.receiver.remote.attach.source.address;
-    this.outstanding[id] = callback;
-    this.sender.send(request);
-};
-
-Client.prototype._response = function (context) {
-    var id = context.message.properties.correlation_id;
-    var callback = this.outstanding[id];
-    if (callback) {
-        if (context.message.properties.subject === 'ok') {
-            callback(context.message.body);
-        } else {
-            callback(undefined, {name: context.message.properties.subject, description: context.message.body});
-        }
-    } else {
-        console.log('no request pending for ' + id + ', ignoring response');
-    }
-};
-
-Client.prototype._ready = function (context) {
-    this._process_pending();
-};
-
-Client.prototype._process_pending = function () {
-    for (var i = 0; i < this.pending.length; i++) {
-        var r = this.pending[i];
-        this._request(r.id, r.name, r.args, r.callback);
-    }
-    this.pending = [];
-};
-
-Client.prototype.call = function (name, args, callback) {
-    var id = this.id_generator.next();
-    if (this.receiver.is_open() && this.pending.length === 0) {
-        this._request(id, name, args, callback);
-    } else {
-        //need to wait for reply-to address
-        this.pending.push({'name':name, 'args':args, 'callback':callback, 'id':id});
-    }
-};
-
-Client.prototype.close = function () {
-    this.receiver.close();
-    this.sender.close();
-    this.connection.close();
-};
-
-Client.prototype.define = function (name) {
-    this[name] = function (args, callback) { this.call(name, args, callback); };
-};
-
-var Cache = function (ttl, purged) {
-    this.ttl = ttl;
-    this.purged = purged;
-    this.entries = {};
-    this.timeout = undefined;
-};
-
-Cache.prototype.clear = function () {
-    if (this.timeout) clearTimeout(this.timeout);
-    this.entries = {};
-}
-
-Cache.prototype.put = function (key, value) {
-    this.entries[key] = {'value':value, 'last_accessed': Date.now()};
-    if (!this.timeout) this.timeout = setTimeout(this.purge.bind(this), this.ttl);
-};
-
-Cache.prototype.get = function (key) {
-    var entry = this.entries[key];
-    if (entry) {
-        entry.last_accessed = Date.now();
-        return entry.value;
-    } else {
-        return undefined;
-    }
-};
-
-Cache.prototype.purge = function() {
-    //TODO: this could be optimised if the map is large
-    var now = Date.now();
-    var expired = [];
-    var live = 0;
-    for (var k in this.entries) {
-        if (now - this.entries[k].last_accessed >= this.ttl) {
-            expired.push(k);
-        } else {
-            live++;
-        }
-    }
-    for (var i = 0; i < expired.length; i++) {
-        var entry = this.entries[expired[i]];
-        delete this.entries[expired[i]];
-        this.purged(entry.value);
-    }
-    if (live && !this.timeout) {
-        this.timeout = setTimeout(this.purge.bind(this), this.ttl);
-    }
-};
-
-var LinkCache = function (factory, ttl) {
-    this.factory = factory;
-    this.cache = new Cache(ttl, function(link) { link.close(); });
-}
-
-LinkCache.prototype.clear = function () {
-    this.cache.clear();
-}
-
-LinkCache.prototype.get = function (address) {
-    var link = this.cache.get(address);
-    if (link === undefined) {
-        link = this.factory(address);
-        this.cache.put(address, link);
-    }
-    return link;
-};
-
-var Server = function (container, address, options) {
-    this.options = options || {};
-    var u = url.parse(address);
-    //TODO: handle scheme and user/password if present
-    this.connection = container.connect({'host':u.hostname, 'port':u.port});
-    this.connection.on('connection_open', this._connection_open.bind(this));
-    this.connection.on('message', this._request.bind(this));
-    this.receiver = this.connection.attach_receiver(u.path.substr(1));
-    this.callbacks = {};
-    this._send = undefined;
-    this._clear = undefined;
-};
-
-function match(desired, offered) {
-    if (offered) {
-        if (Array.isArray(offered)) {
-            return offered.indexOf(desired) > -1;
-        } else {
-            return desired === offered;
-        }
-    } else {
-        return false;
-    }
-}
-
-Server.prototype._connection_open = function (context) {
-    if (match('ANONYMOUS-RELAY', this.connection.remote.open.offered_capabilities)) {
-        var relay = this.connection.attach_sender({target:{}});
-        this._send = function (msg) { relay.send(msg); };
-    } else {
-        var cache = new LinkCache(this.connection.attach_sender.bind(this.connection), this.options.cache_ttl || 60000);
-        this._send = function (msg) { var s = cache.get(msg.properties.to); if (s) s.send(msg); };
-        this._clear = function () { cache.clear(); }
-    }
-}
-
-Server.prototype._respond = function (response) {
-    var server = this;
-    return function (result, error) {
-        if (error) {
-            response.properties.subject = error.name || 'error';
-            response.body = error.description || error;
-        } else {
-            response.properties.subject = 'ok';
-            response.body = result;
-        }
-        server._send(response);
-    };
-}
-
-Server.prototype._request = function (context) {
-    var request = context.message;
-    var response = {properties:{}};
-    response.properties.to = request.properties.reply_to;
-    response.properties.correlation_id = request.properties.message_id;
-    var callback = this.callbacks[request.properties.subject];
-    if (callback) {
-        callback(request.body, this._respond(response));
-    } else {
-        response.properties.subject = 'bad-method';
-        response.body = 'Unrecognised method ' + request.properties.subject;
-        this._send(response);
-    }
-};
-
-Server.prototype.bind_sync = function (f, name) {
-    this.callbacks[name || f.name] = function (args, callback) { var result = f(args); callback(result); };
-};
-Server.prototype.bind = function (f, name) {
-    this.callbacks[name || f.name] = f;
-};
-
-Server.prototype.close = function () {
-    if (this._clear) this._clear();
-    this.receiver.close();
-    this.connection.close();
-};
-
-module.exports = {
-    server : function(container, address, options) { return new Server(container, address, options); },
-    client : function(connection, address) { return new Client(connection, address); }
-};
-
-},{"url":29}],8:[function(require,module,exports){
-(function (Buffer){
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-'use strict';
-
-var frames = require('./frames.js');
-var log = require('./log.js');
-var Transport = require('./transport.js');
-
-var sasl_codes = {
-    "OK":0,
-    "AUTH":1,
-    "SYS":2,
-    "SYS_PERM":3,
-    "SYS_TEMP":4,
-};
-
-var SASL_PROTOCOL_ID = 0x03;
-
-function intersection(lista, listb) {
-    return lista.filter(function (a) { return listb.indexOf(a) >= 0; });
-}
-function extract(buffer) {
-    var results = [];
-    var start = 0;
-    var i = 0;
-    while (i < buffer.length) {
-        if (buffer[i] === 0x00) {
-            if (i > start) results.push(buffer.toString('utf8', start, i));
-            else results.push(null);
-            start = ++i;
-        } else {
-            ++i;
-        }
-    }
-    if (i > start) results.push(buffer.toString('utf8', start, i));
-    else results.push(null);
-    return results;
-}
-
-var PlainServer = function(callback) {
-    this.callback = callback;
-    this.outcome = undefined;
-    this.username = undefined;
-};
-
-PlainServer.prototype.start = function(response) {
-    var fields = extract(response);
-    if (fields.length !== 3) {
-        this.connection.sasl_failed('Unexpected response in PLAIN, got ' + fields.length + ' fields, expected 3');
-    }
-    if (this.callback(fields[1], fields[2])) {
-        this.outcome = true;
-        this.username = fields[1];
-    } else {
-        this.outcome = false;
-    }
-};
-
-var PlainClient = function(username, password) {
-    this.username = username;
-    this.password = password;
-};
-
-PlainClient.prototype.start = function() {
-    var response = new Buffer(1 + this.username.length + 1 + this.password.length);
-    response.writeUInt8(0, 0);
-    response.write(this.username, 1);
-    response.writeUInt8(0, 1 + this.username.length);
-    response.write(this.password, 1 + this.username.length + 1);
-    return response;
-};
-
-var AnonymousServer = function() {
-    this.outcome = undefined;
-    this.username = undefined;
-};
-
-AnonymousServer.prototype.start = function(response) {
-    this.outcome = true;
-    this.username = response ? response.toString('utf8') : 'anonymous';
-};
-
-var AnonymousClient = function(name) {
-    this.username = name ? name : 'anonymous';
-};
-
-AnonymousClient.prototype.start = function() {
-    var response = new Buffer(1 + this.username.length);
-    response.writeUInt8(0, 0);
-    response.write(this.username, 1);
-    return response;
-};
-
-var ExternalServer = function() {
-    this.outcome = undefined;
-    this.username = undefined;
-};
-
-ExternalServer.prototype.start = function(response) {
-    this.outcome = true;
-};
-
-var ExternalClient = function() {
-    this.username = undefined;
-};
-
-ExternalClient.prototype.start = function() {
-    return null;
-};
-
-/**
- * The mechanisms argument is a map of mechanism names to factory
- * functions for objects that implement that mechanism.
- */
-var SaslServer = function (connection, mechanisms) {
-    this.connection = connection;
-    this.transport = new Transport(connection.amqp_transport.identifier, SASL_PROTOCOL_ID, frames.TYPE_SASL, this);
-    this.next = connection.amqp_transport;
-    this.mechanisms = mechanisms;
-    this.mechanism = undefined;
-    this.outcome = undefined;
-    this.username = undefined;
-    var mechlist = Object.getOwnPropertyNames(mechanisms);
-    this.transport.encode(frames.sasl_frame(frames.sasl_mechanisms({sasl_server_mechanisms:mechlist}).described()));
-};
-
-SaslServer.prototype.do_step = function (challenge) {
-    if (this.mechanism.outcome === undefined) {
-        this.transport.encode(frames.sasl_frame(frames.sasl_challenge({'challenge':challenge}).described()));
-    } else {
-        this.outcome = this.mechanism.outcome ? sasl_codes.OK : sasl_codes.AUTH;
-        this.transport.encode(frames.sasl_frame(frames.sasl_outcome({code: this.outcome}).described()));
-        if (this.outcome === sasl_codes.OK) {
-            this.username = this.mechanism.username;
-            this.transport.write_complete = true;
-            this.transport.read_complete = true;
-        }
-    }
-};
-
-SaslServer.prototype.on_sasl_init = function (frame) {
-    var f = this.mechanisms[frame.performative.mechanism];
-    if (f) {
-        this.mechanism = f();
-        var challenge = this.mechanism.start(frame.performative.initial_response);
-        this.do_step(challenge);
-    } else {
-        this.outcome = sasl_codes.AUTH;
-        this.transport.encode(frames.sasl_frame(frames.sasl_outcome({code: this.outcome}).described()));
-    }
-};
-SaslServer.prototype.on_sasl_response = function (frame) {
-    this.do_step(this.mechanism.step(frame.performative.response));
-};
-
-SaslServer.prototype.has_writes_pending = function () {
-    return this.transport.has_writes_pending() || this.next.has_writes_pending();
-}
-
-SaslServer.prototype.write = function (socket) {
-    if (this.transport.write_complete && this.transport.pending.length === 0) {
-        return this.next.write(socket);
-    } else {
-        return this.transport.write(socket);
-    }
-};
-
-SaslServer.prototype.read = function (buffer) {
-    if (this.transport.read_complete) {
-        return this.next.read(buffer);
-    } else {
-        return this.transport.read(buffer);
-    }
-};
-
-var SaslClient = function (connection, mechanisms) {
-    this.connection = connection;
-    this.transport = new Transport(connection.amqp_transport.identifier, SASL_PROTOCOL_ID, frames.TYPE_SASL, this);
-    this.next = connection.amqp_transport;
-    this.mechanisms = mechanisms;
-    this.mechanism = undefined;
-    this.mechanism_name = undefined;
-    this.failed = false;
-};
-
-SaslClient.prototype.on_sasl_mechanisms = function (frame) {
-    for (var i = 0; this.mechanism === undefined && i < frame.performative.sasl_server_mechanisms.length; i++) {
-        var mech = frame.performative.sasl_server_mechanisms[i];
-        var f = this.mechanisms[mech];
-        if (f) {
-            this.mechanism = f();
-            this.mechanism_name = mech;
-        }
-    }
-    if (this.mechanism) {
-        var response = this.mechanism.start();
-        this.transport.encode(frames.sasl_frame(frames.sasl_init({'mechanism':this.mechanism_name,'initial_response':response}).described()));
-    } else {
-        this.failed = true;
-        this.connection.sasl_failed('No suitable mechanism; server supports ' + frame.performative.sasl_server_mechanisms);
-    }
-};
-SaslClient.prototype.on_sasl_challenge = function (frame) {
-    var response = this.mechanism.step(frame.performative.challenge);
-    this.transport.encode(frames.sasl_frame(frames.sasl_response({'response':response}).described()));
-};
-SaslClient.prototype.on_sasl_outcome = function (frame) {
-    switch (frame.performative.code) {
-    case sasl_codes.OK:
-        this.transport.read_complete = true;
-        this.transport.write_complete = true;
-        break;
-    default:
-        this.transport.write_complete = true;
-        this.connection.sasl_failed("Failed to authenticate: " + frame.performative.code);
-    }
-};
-
-SaslClient.prototype.has_writes_pending = function () {
-    return this.transport.has_writes_pending() || this.next.has_writes_pending();
-}
-
-SaslClient.prototype.write = function (socket) {
-    if (this.transport.write_complete) {
-        return this.next.write(socket);
-    } else {
-        return this.transport.write(socket);
-    }
-};
-
-SaslClient.prototype.read = function (buffer) {
-    if (this.transport.read_complete) {
-        return this.next.read(buffer);
-    } else {
-        return this.transport.read(buffer);
-    }
-};
-
-var default_server_mechanisms = {
-    enable_anonymous: function () {
-        this['ANONYMOUS'] = function() { return new AnonymousServer(); };
-    },
-    enable_plain: function (callback) {
-        this['PLAIN'] = function() { return new PlainServer(callback); };
-    }
-};
-
-var default_client_mechanisms = {
-    enable_anonymous: function (name) {
-        this['ANONYMOUS'] = function() { return new AnonymousClient(name); };
-    },
-    enable_plain: function (username, password) {
-        this['PLAIN'] = function() { return new PlainClient(username, password); };
-    },
-    enable_external: function () {
-        this['EXTERNAL'] = function() { return new ExternalClient(); };
-    }
-};
-
-module.exports = {
-    Client : SaslClient,
-    Server : SaslServer,
-    server_mechanisms : function () {
-        return Object.create(default_server_mechanisms);
-    },
-    client_mechanisms : function () {
-        return Object.create(default_client_mechanisms);
-    },
-    server_add_external: function (mechs) {
-        mechs['EXTERNAL'] = function() { return new ExternalServer(); };
-        return mechs;
-    }
-};
-
-}).call(this,require("buffer").Buffer)
-},{"./frames.js":3,"./log.js":5,"./transport.js":11,"buffer":19}],9:[function(require,module,exports){
-(function (Buffer){
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-'use strict';
-
-var frames = require('./frames.js');
-var link = require('./link.js');
-var log = require('./log.js');
-var message = require('./message.js');
-var types = require('./types.js');
-var util = require('./util.js');
-var EndpointState = require('./endpoint.js');
-
-var EventEmitter = require('events').EventEmitter;
-
-var CircularBuffer = function (capacity) {
-    this.capacity = capacity;
-    this.size = 0;
-    this.head = 0;
-    this.tail = 0;
-    this.entries = [];
-};
-
-CircularBuffer.prototype.available = function () {
-    return this.capacity - this.size;
-};
-
-CircularBuffer.prototype.push = function (o) {
-    if (this.size < this.capacity) {
-        this.entries[this.tail] = o;
-        this.tail = (this.tail + 1) % this.capacity;
-        this.size++;
-    } else {
-        throw Error('circular buffer overflow: head=' + this.head + ' tail=' + this.tail + ' size=' + this.size + ' capacity=' + this.capacity);
-    }
-};
-
-CircularBuffer.prototype.pop_if = function (f) {
-    var count = 0;
-    while (this.size && f(this.entries[this.head])) {
-        this.entries[this.head] = undefined;
-        this.head = (this.head + 1) % this.capacity;
-        this.size--;
-        count++;
-    }
-    return count;
-};
-
-CircularBuffer.prototype.by_id = function (id) {
-    if (this.size > 0) {
-        var gap = id - this.entries[this.head].id;
-        if (gap < this.size) {
-            return this.entries[(this.head + gap) % this.capacity];
-        }
-    }
-    return undefined;
-};
-
-CircularBuffer.prototype.get_head = function (id) {
-    return this.size > 0 ? this.entries[this.head] : undefined;
-};
-
-
-var Outgoing = function () {
-    this.deliveries = new CircularBuffer(2048/*TODO= configurable?*/);
-    this.updated = [];
-    this.next_delivery_id = 0;
-    this.next_pending_delivery = 0;
-    this.next_transfer_id = 0;
-    this.window = types.MAX_UINT;
-    this.remote_next_transfer_id = undefined;
-    this.remote_window = undefined;
-};
-
-Outgoing.prototype.available = function () {
-    return this.deliveries.available();
-};
-
-Outgoing.prototype.send = function (sender, tag, data, format) {
-    var d = {'id':this.next_delivery_id++,
-             'tag':tag,
-             'link':sender,
-             'data': data,
-             'format':format ? format : 0,
-             'sent': false,
-             'settled': false,
-             'state': undefined,
-             'remote_settled': false,
-             'remote_state': undefined};
-    this.deliveries.push(d);
-    return d;
-};
-
-Outgoing.prototype.on_begin = function (fields) {
-    this.remote_window = fields.incoming_window;
-};
-
-Outgoing.prototype.on_flow = function (fields) {
-    this.remote_next_transfer_id = fields.next_incoming_id;
-    this.remote_window = fields.incoming_window;
-};
-
-Outgoing.prototype.on_disposition = function (fields) {
-    var last = fields.last ? fields.last : fields.first;
-    for (var i = fields.first; i <= last; i++) {
-        var d = this.deliveries.by_id(i);
-        if (!d) {
-            console.log('Could not find delivery for ' + i + ' [' + JSON.stringify(fields) + ']');
-        }
-        if (d && !d.remote_settled) {
-            var updated = false;
-            if (fields.settled) {
-                d.remote_settled = fields.settled;
-                updated = true;
-            }
-            if (fields.state && fields.state !== d.remote_state) {
-                d.remote_state = fields.state;
-                updated = true;
-            }
-            if (updated) {
-                this.updated.push(d);
-            }
-        }
-    }
-};
-
-Outgoing.prototype.transfer_window = function() {
-    if (this.remote_window) {
-        return this.remote_window - (this.next_transfer_id - this.remote_next_transfer_id);
-    }
-};
-
-Outgoing.prototype.process = function() {
-    // send pending deliveries for which there is credit:
-    while (this.next_pending_delivery < this.next_delivery_id) {
-        var d = this.deliveries.by_id(this.next_pending_delivery);
-        if (d) {
-            if (d.link.has_credit()) {
-                d.link.delivery_count++;
-                //TODO: fragment as appropriate
-                d.transfers_required = 1;
-                if (this.transfer_window() >= d.transfers_required) {
-                    this.next_transfer_id += d.transfers_required;
-                    this.window -= d.transfers_required;
-                    d.link.session.output(frames.transfer({'handle':d.link.local.handle,'message_format':d.format,'delivery_id':d.id, 'delivery_tag':d.tag}).described(), d.data);
-                    d.link.credit--;
-                    this.next_pending_delivery++;
-                } else {
-                    log.flow('Incoming window of peer preventing sending further transfers: remote_window=' + this.remote_window + ", remote_next_transfer_id=" + this.remote_next_transfer_id
-                               + ", next_transfer_id=" + this.next_transfer_id);
-                    break;
-                }
-            } else {
-                log.flow('Link has no credit');
-                break;
-            }
-        } else {
-            console.log('ERROR: Next pending delivery not found: ' + this.next_pending_delivery);
-            break;
-        }
-    }
-
-    // notify application of any updated deliveries:
-    for (var i = 0; i < this.updated.length; i++) {
-        var d = this.updated[i];
-        if (d.remote_state) {
-            d.remote_state = message.unwrap_outcome(d.remote_state);
-            if (d.remote_state && d.remote_state.constructor.composite_type) {
-                d.link.dispatch(d.remote_state.constructor.composite_type, d.link._context({'delivery':d}));
-            }
-        }
-        if (d.remote_settled) d.link.dispatch('settled', d.link._context({'delivery':d}));
-    }
-    this.updated = [];
-
-    // remove any fully settled deliveries:
-    this.deliveries.pop_if(function (d) { return d.settled && d.remote_settled; });
-};
-
-var Incoming = function () {
-    this.deliveries = new CircularBuffer(2048/*TODO: configurable?*/);
-    this.updated = [];
-    this.next_transfer_id = 0;
-    this.next_delivery_id = undefined;
-    this.window = 2048/*TODO: configurable?*/;
-    this.remote_next_transfer_id = undefined;
-    this.remote_window = undefined;
-};
-
-Incoming.prototype.update = function (delivery, settled, state) {
-    if (delivery) {
-        delivery.settled = settled;
-        if (state !== undefined) delivery.state = state;
-        if (!delivery.remote_settled) {
-            this.updated.push(delivery);
-        }
-        delivery.link.connection._register();
-    }
-};
-
-Incoming.prototype.on_transfer = function(frame, receiver) {
-    this.next_transfer_id++;
-    if (receiver.is_open()) {
-        if (this.next_delivery_id === undefined) {
-            this.next_delivery_id = frame.performative.delivery_id;
-        }
-        var current;
-        var data;
-        var last = this.deliveries.get_head();
-        if (last && last.incomplete) {
-            if (frame.performative.delivery_id !== undefined && this.next_delivery_id != frame.performative.delivery_id) {
-                //TODO: better error handling
-                throw Error("frame sequence error: delivery " + this.next_delivery_id + " not complete, got " + frame.performative.delivery_id);
-            }
-            current = last;
-            data = Buffer.concat([current.data, frame.payload], current.data.size() + frame.payload.size());
-        } else if (this.next_delivery_id === frame.performative.delivery_id) {
-            current = {'id':frame.performative.delivery_id,
-                       'tag':frame.performative.delivery_tag,
-                       'link':receiver,
-                       'settled': false,
-                       'state': undefined,
-                       'remote_settled': frame.performative.settled,
-                       'remote_state': undefined};
-            var self = this;
-            current.update = function (settled, state) { self.update(current, settled, state); };
-            this.deliveries.push(current);
-            data = frame.payload;
-        } else {
-            //TODO: better error handling
-            throw Error("frame sequence error: expected " + this.next_delivery_id + ", got " + frame.performative.delivery_id);
-        }
-        current.incomplete = frame.performative.more;
-        if (current.incomplete) {
-            current.data = data;
-        } else {
-            receiver.credit--;
-            receiver.delivery_count++;
-            this.next_delivery_id++;
-            receiver.dispatch('message', receiver._context({'message':message.decode(data), 'delivery':current}));
-        }
-    }
-};
-
-Incoming.prototype.process = function () {
-    if (this.updated.length > 0) {
-        var first;
-        var last;
-        var next_id;
-
-        for (var i = 0; i < this.updated.length; i++) {
-            var delivery = this.updated[i];
-            if (first === undefined) {
-                first = delivery;
-                last = delivery;
-                next_id = delivery.id;
-            }
-
-            if (!message.are_outcomes_equivalent(last.state, delivery.state) || last.settled !== delivery.settled || next_id !== delivery.id) {
-                first.link.session.output(frames.disposition({'role':true,'first':first.id,'last':last.id, 'state':first.state, 'settled':first.settled}).described());
-                first = delivery;
-                last = delivery;
-                next_id = delivery.id;
-            } else {
-                if (last.id !== delivery.id) {
-                    last = delivery;
-                }
-                next_id++;
-            }
-        }
-        if (first !== undefined && last !== undefined) {
-            first.link.session.output(frames.disposition({'role':true,'first':first.id,'last':last.id, 'state':first.state, 'settled':first.settled}).described());
-        }
-
-        this.updated = [];
-    }
-
-    // remove any fully settled deliveries:
-    this.deliveries.pop_if(function (d) { return d.settled; });
-};
-
-Incoming.prototype.on_begin = function (fields) {
-    this.remote_window = fields.outgoing_window;
-};
-
-Incoming.prototype.on_flow = function (fields) {
-    this.remote_next_transfer_id = fields.next_outgoing_id;
-    this.remote_window = fields.outgoing_window;
-};
-
-Incoming.prototype.on_disposition = function (fields) {
-    var last = fields.last ? fields.last : fields.first;
-    for (var i = fields.first; i <= last; i++) {
-        var d = this.deliveries.by_id(i);
-        if (!d) {
-            console.log('Could not find delivery for ' + i);
-        }
-        if (d && !d.remote_settled) {
-            var updated = false;
-            if (fields.settled) {
-                d.remote_settled = fields.settled;
-                updated = true;
-            }
-            if (fields.state && fields.state !== d.remote_state) {
-                d.remote_state = fields.state;
-                updated = true;
-            }
-            if (updated) {
-                console.log(d.link.connection.options.id + ' added delivery to updated list following receipt of disposition for incoming deliveries');
-                this.updated.push(d);
-            }
-        }
-    }
-
-};
-
-var Session = function (connection, local_channel) {
-    this.connection = connection;
-    this.outgoing = new Outgoing();
-    this.incoming = new Incoming();
-    this.state = new EndpointState();
-    this.local = {'channel': local_channel, 'handles':{}};
-    this.local.begin = frames.begin({next_outgoing_id:this.outgoing.next_transfer_id,incoming_window:this.incoming.window,outgoing_window:this.outgoing.window});
-    this.local.end = frames.end();
-    this.remote = {'handles':{}};
-    this.links = {}; // map by name
-    this.options = {};
-};
-Session.prototype = Object.create(EventEmitter.prototype);
-Session.prototype.constructor = Session;
-
-Session.prototype.reset = function() {
-    this.state.disconnected();
-    this.outgoing = new Outgoing();
-    this.incoming = new Incoming();
-    this.remote = {'handles':{}};
-    for (var l in this.links) {
-        this.links[l].reset();
-    }
-};
-
-Session.prototype.dispatch = function(name, context) {
-    log.events('Session got event: '+ name);
-    if (this.listeners(name).length) {
-        EventEmitter.prototype.emit.apply(this, arguments);
-    } else {
-        this.connection.dispatch.apply(this.connection, arguments);
-    }
-};
-Session.prototype.output = function (frame, payload) {
-    this.connection._write_frame(this.local.channel, frame, payload);
-};
-
-Session.prototype.create_sender = function (name, opts) {
-    return this.create_link(name, link.Sender, opts);
-};
-
-Session.prototype.create_receiver = function (name, opts) {
-    return this.create_link(name, link.Receiver, opts);
-};
-
-function attach(factory, args, remote_terminus) {
-    var opts = args ? args : {};
-    if (typeof args === 'string') {
-        opts = {};
-        opts[remote_terminus] = args;
-    }
-    if (!opts.name) opts.name = util.generate_uuid();
-    var l = factory(opts.name, opts);
-    for (var t in {'source':0, 'target':0}) {
-        if (opts[t]) {
-            if (typeof opts[t] === 'string') {
-                opts[t] = {'address' : opts[t]};
-            }
-            l['set_' + t](opts[t]);
-        }
-    }
-    l.attach();
-    return l;
-}
-
-Session.prototype.get_option = function (name, default_value) {
-    if (this.options[name] !== undefined) return this.options[name];
-    else return this.connection.get_option(name, default_value);
-};
-
-Session.prototype.attach_sender = function (args) {
-    return attach(this.create_sender.bind(this), args, 'target');
-};
-Session.prototype.open_sender = Session.prototype.attach_sender;//alias
-
-Session.prototype.attach_receiver = function (args) {
-    return attach(this.create_receiver.bind(this), args, 'source');
-};
-Session.prototype.open_receiver = Session.prototype.attach_receiver;//alias
-
-Session.prototype.create_link = function (name, constructor, opts) {
-    var i = 0;
-    while (this.local.handles[i]) i++;
-    var l = new constructor(this, name, i, opts);
-    this.links[name] = l;
-    this.local.handles[i] = l;
-    return l;
-};
-
-Session.prototype.begin = function () {
-    if (this.state.open()) {
-        this.connection._register();
-    }
-};
-Session.prototype.open = Session.prototype.begin;
-
-Session.prototype.end = function () {
-    if (this.state.close()) {
-        this.connection._register();
-    }
-};
-Session.prototype.close = Session.prototype.end;
-
-Session.prototype.is_open = function () {
-    return this.connection.is_open() && this.state.is_open();
-};
-
-Session.prototype.is_closed = function () {
-    return this.connection.is_closed() || this.state.is_closed();
-};
-
-Session.prototype._process = function () {
-    do {
-        if (this.state.need_open()) {
-            this.output(this.local.begin.described());
-        }
-
-        this.outgoing.process();
-        this.incoming.process();
-        for (var k in this.links) {
-            this.links[k]._process();
-        }
-
-        if (this.state.need_close()) {
-            this.output(this.local.end.described());
-        }
-    } while (!this.state.has_settled());
-};
-
-Session.prototype.send = function (sender, tag, data, format) {
-    var d = this.outgoing.send(sender, tag, data, format);
-    this.connection._register();
-    return d;
-};
-
-Session.prototype._write_flow = function (link) {
-    var fields = {'next_incoming_id':this.incoming.next_transfer_id,
-                  'incoming_window':this.incoming.window,
-                  'next_outgoing_id':this.outgoing.next_transfer_id,
-                  'outgoing_window':this.outgoing.window
-                 };
-    if (link) {
-        fields.delivery_count = link.delivery_count;
-        fields.handle = link.local.handle;
-        fields.link_credit = link.credit;
-    }
-    this.output(frames.flow(fields).described());
-};
-
-Session.prototype.on_begin = function (frame) {
-    if (this.state.remote_opened()) {
-        if (!this.remote.channel) {
-            this.remote.channel = frame.channel;
-        }
-        this.remote.begin = frame.performative;
-        this.outgoing.on_begin(frame.performative);
-        this.incoming.on_begin(frame.performative);
-        this.open();
-        this.dispatch('session_open', this._context());
-    } else {
-        throw Error('Begin already received');
-    }
-};
-Session.prototype.on_end = function (frame) {
-    if (this.state.remote_closed()) {
-        this.remote.end = frame.performative;
-        this.close();
-        this.dispatch('session_close', this._context());
-    } else {
-        throw Error('End already received');
-    }
-};
-
-Session.prototype.on_attach = function (frame) {
-    var name = frame.performative.name;
-    var link = this.links[name];
-    if (!link) {
-        // if role is true, peer is receiver, so we are sender
-        link = frame.performative.role ? this.create_sender(name) : this.create_receiver(name);
-    }
-    this.remote.handles[frame.performative.handle] = link;
-    link.on_attach(frame);
-    link.remote.attach = frame.performative;
-};
-
-Session.prototype.on_disposition = function (frame) {
-    if (frame.performative.role) {
-        log.events('Received disposition for outgoing transfers');
-        this.outgoing.on_disposition(frame.performative);
-    } else {
-        log.events('Received disposition for incoming transfers');
-        this.incoming.on_disposition(frame.performative);
-    }
-    this.connection._register();
-}
-
-Session.prototype.on_flow = function (frame) {
-    this.outgoing.on_flow(frame.performative);
-    this.incoming.on_flow(frame.performative);
-    if (frame.performative.handle !== undefined) {
-        this._get_link(frame).on_flow(frame);
-    }
-    this.connection._register();
-}
-Session.prototype._context = function (c) {
-    var context = c ? c : {};
-    context.session = this;
-    return this.connection._context(context);
-};
-
-Session.prototype._get_link = function (frame) {
-    var handle = frame.performative.handle;
-    var link = this.remote.handles[handle];
-    if (!link) {
-        throw Error('Invalid handle ' + handle);
-    }
-    return link;
-};
-
-Session.prototype.on_detach = function (frame) {
-    this._get_link(frame).on_detach(frame);
-    //remove link
-    var handle = frame.performative.handle;
-    var link = this.remote.handles[handle];
-    delete this.remote.handles[handle];
-    delete this.local.handles[link.local.handle];
-    delete this.links[link.name];
-};
-
-Session.prototype.on_transfer = function (frame) {
-    this.incoming.on_transfer(frame, this._get_link(frame));
-};
-
-module.exports = Session;
-
-}).call(this,require("buffer").Buffer)
-},{"./endpoint.js":2,"./frames.js":3,"./link.js":4,"./log.js":5,"./message.js":6,"./types.js":12,"./util.js":13,"buffer":19,"events":23}],10:[function(require,module,exports){
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-'use strict';
-
-var types = require('./types.js');
-
-var terminus = {};
-var by_descriptor = {};
-
-function define_terminus(def) {
-    var c = types.define_composite(def);
-    terminus[def.name] = c.create;
-    by_descriptor[Number(c.descriptor.numeric).toString(10)] = c;
-    by_descriptor[c.descriptor.symbolic] = c;
-};
-
-terminus.unwrap = function(field) {
-    if (field && field.descriptor) {
-        var c = by_descriptor[field.descriptor.value];
-        if (c) {
-            return new c(field.value)
-        } else {
-            console.log('Unknown terminus: ' + field.descriptor);
-        }
-    }
-    return null;
-};
-
-define_terminus(
-    {name:"source",
-     code:0x28,
-     fields: [
-         {name:"address", type:"string"},
-         {name:"durable", type:"uint", default_value:0},
-         {name:"expiry_policy", type:"symbol", default_value:"session-end"},
-         {name:"timeout", type:"uint", default_value:0},
-         {name:"dynamic", type:"boolean", default_value:false},
-         {name:"dynamic_node_properties", type:"symbolic_map"},
-         {name:"distribution_mode", type:"symbol"},
-         {name:"filter", type:"symbolic_map"},
-         {name:"default_outcome", type:"*"},
-         {name:"outcomes", type:"symbol", multiple:true},
-         {name:"capabilities", type:"symbol", multiple:true}
-     ]
-    });
-
-define_terminus(
-    {name:"target",
-     code:0x29,
-     fields: [
-         {name:"address", type:"string"},
-         {name:"durable", type:"uint", default_value:0},
-         {name:"expiry_policy", type:"symbol", default_value:"session-end"},
-         {name:"timeout", type:"uint", default_value:0},
-         {name:"dynamic", type:"boolean", default_value:false},
-         {name:"dynamic_node_properties", type:"symbolic_map"},
-         {name:"capabilities", type:"symbol", multiple:true}
-     ]
-    });
-
-module.exports = terminus;
-
-},{"./types.js":12}],11:[function(require,module,exports){
-(function (Buffer){
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "Lic

<TRUNCATED>

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[6/6] qpid-dispatch git commit: Added license text for rhea-min.js

Posted by ea...@apache.org.
Added license text for rhea-min.js


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/e1c7255a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/e1c7255a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/e1c7255a

Branch: refs/heads/master
Commit: e1c7255a3e571bb3913a4c3fa8ab785ef7c3b280
Parents: f60fd9f
Author: Ernest Allen <ea...@redhat.com>
Authored: Mon Feb 22 12:15:26 2016 -0500
Committer: Ernest Allen <ea...@redhat.com>
Committed: Mon Feb 22 12:15:26 2016 -0500

----------------------------------------------------------------------
 LICENSE | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e1c7255a/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 261eeb9..e7e4b0d 100644
--- a/LICENSE
+++ b/LICENSE
@@ -199,3 +199,11 @@
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
+
+
+###############################################
+# Thrid Party Dependency Licensing Information:
+###############################################
+
+console/stand-alone/plugin/lib/rhea-min.js 
+is Licensed under the above Apache License, Version 2.0


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[5/6] qpid-dispatch git commit: removed rhea.js and use rhea-min.js

Posted by ea...@apache.org.
removed rhea.js and use rhea-min.js


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/f60fd9f6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/f60fd9f6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/f60fd9f6

Branch: refs/heads/master
Commit: f60fd9f66549c3fef46b9e38e7db697b42cfa05b
Parents: f9ba97f
Author: Ernest Allen <ea...@redhat.com>
Authored: Mon Feb 22 12:14:45 2016 -0500
Committer: Ernest Allen <ea...@redhat.com>
Committed: Mon Feb 22 12:14:45 2016 -0500

----------------------------------------------------------------------
 console/stand-alone/plugin/lib/rhea.js | 7716 ---------------------------
 1 file changed, 7716 deletions(-)
----------------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org