diff --git a/Gruntfile.js b/Gruntfile.js index e60ea5b..6296195 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,13 +12,7 @@ module.exports = function(grunt) { default: { files: { 'build/wampy.min.js': ['src/wampy.js'], - 'build/msgpack.min.js': ['src/msgpack/src/msgpack.js'], - 'build/jdataview.min.js': ['src/jdataview/src/jdataview.js'], - 'build/wampy-all.min.js': [ - 'src/jdataview/src/jdataview.js', - 'src/msgpack/src/msgpack.js', - 'src/wampy.js' - ] + 'build/msgpack.min.js': ['src/msgpack/src/msgpack.js'] } } }, @@ -29,12 +23,30 @@ module.exports = function(grunt) { default: { src: 'src/wampy.js' } + }, + concat: { + wampy: { + src: ['build/jdataview.min.js', 'build/msgpack.min.js', 'build/wampy.min.js'], + dest: 'build/wampy-all.min.js' + } + }, + copy: { + main: { + files: [ + { + src: ['src/jdataview/dist/browser/jdataview.js'], + dest: 'build/jdataview.min.js' + } + ] + } } }); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-copy'); grunt.registerTask('test', ['jshint']); - grunt.registerTask('default', ['uglify']); + grunt.registerTask('default', ['uglify', 'copy', 'concat']); }; diff --git a/build/jdataview.min.js b/build/jdataview.min.js index b894d64..88f261b 100644 --- a/build/jdataview.min.js +++ b/build/jdataview.min.js @@ -1 +1,2 @@ -function arrayFrom(a,b){return!b&&a instanceof Array?a:Array.prototype.slice.call(a)}function defined(a,b){return void 0!==a?a:b}function jDataView(a,b,c,d){if(a instanceof jDataView){var e=a.slice(b,b+c);return e._littleEndian=defined(d,e._littleEndian),e}if(!(this instanceof jDataView))return new jDataView(a,b,c,d);if(this.buffer=a=jDataView.wrapBuffer(a),this._isArrayBuffer=compatibility.ArrayBuffer&&a instanceof ArrayBuffer,this._isPixelData=BROWSER&&compatibility.PixelData&&a instanceof CanvasPixelArray,this._isDataView=compatibility.DataView&&this._isArrayBuffer,this._isNodeBuffer=NODE&&compatibility.NodeBuffer&&a instanceof Buffer,!(NODE&&this._isNodeBuffer||this._isArrayBuffer||BROWSER&&this._isPixelData||a instanceof Array))throw new TypeError("jDataView buffer has an incompatible type");this._littleEndian=!!d;var f="byteLength"in a?a.byteLength:a.length;this.byteOffset=b=defined(b,0),this.byteLength=c=defined(c,f-b),this._offset=this._bitOffset=0,this._isDataView?this._view=new DataView(a,b,c):this._checkBounds(b,c,f),this._engineAction=this._isDataView?this._dataViewAction:NODE&&this._isNodeBuffer?this._nodeBufferAction:this._isArrayBuffer?this._arrayBufferAction:this._arrayAction}function getCharCodes(a){if(NODE&&compatibility.NodeBuffer)return new Buffer(a,"binary");for(var b=compatibility.ArrayBuffer?Uint8Array:Array,c=new b(a.length),d=0,e=a.length;e>d;d++)c[d]=255&a.charCodeAt(d);return c}function pow2(a){return a>=0&&31>a?1<d;d++)c[d]=b[d];return c};createPixelData.context2d=document.createElement("canvas").getContext("2d")}var dataTypes={Int8:1,Int16:2,Int32:4,Uint8:1,Uint16:2,Uint32:4,Float32:4,Float64:8};jDataView.wrapBuffer=function(a){switch(typeof a){case"number":if(NODE&&compatibility.NodeBuffer)a=new Buffer(a),a.fill(0);else if(compatibility.ArrayBuffer)a=new Uint8Array(a).buffer;else if(BROWSER&&compatibility.PixelData)a=createPixelData(a);else{a=new Array(a);for(var b=0;b=0){var d=Uint64.fromNumber(a);b=d.lo,c=d.hi}else c=Math.floor(a/pow2(32)),b=a-c*pow2(32),c+=pow2(32);return new Int64(b,c)};var proto=jDataView.prototype={compatibility:compatibility,_checkBounds:function(a,b,c){if("number"!=typeof a)throw new TypeError("Offset is not a number.");if("number"!=typeof b)throw new TypeError("Size is not a number.");if(0>b)throw new RangeError("Length is negative.");if(0>a||a+b>defined(c,this.byteLength))throw new RangeError("Offsets are out of bounds.")},_action:function(a,b,c,d,e){return this._engineAction(a,b,defined(c,this._offset),defined(d,this._littleEndian),e)},_dataViewAction:function(a,b,c,d,e){return this._offset=c+dataTypes[a],b?this._view["get"+a](c,d):this._view["set"+a](c,e,d)},_arrayBufferAction:function(a,b,c,d,e){var f,g=dataTypes[a],h=global[a+"Array"];if(d=defined(d,this._littleEndian),1===g||(this.byteOffset+c)%g===0&&d)return f=new h(this.buffer,this.byteOffset+c,1),this._offset=c+g,b?f[0]:f[0]=e;var i=new Uint8Array(b?this.getBytes(g,c,d,!0):g);return f=new h(i.buffer,0,1),b?f[0]:(f[0]=e,void this._setBytes(c,i,d))},_arrayAction:function(a,b,c,d,e){return b?this["_get"+a](c,d):this["_set"+a](c,e,d)},_getBytes:function(a,b,c){c=defined(c,this._littleEndian),b=defined(b,this._offset),a=defined(a,this.byteLength-b),this._checkBounds(b,a),b+=this.byteOffset,this._offset=b-this.byteOffset+a;var d=this._isArrayBuffer?new Uint8Array(this.buffer,b,a):(this.buffer.slice||Array.prototype.slice).call(this.buffer,b,b+a);return c||1>=a?d:arrayFrom(d).reverse()},getBytes:function(a,b,c,d){var e=this._getBytes(a,b,defined(c,!0));return d?arrayFrom(e):e},_setBytes:function(a,b,c){var d=b.length;if(0!==d){if(c=defined(c,this._littleEndian),a=defined(a,this._offset),this._checkBounds(a,d),!c&&d>1&&(b=arrayFrom(b,!0).reverse()),a+=this.byteOffset,this._isArrayBuffer)new Uint8Array(this.buffer,a,d).set(b);else if(NODE&&this._isNodeBuffer)new Buffer(b).copy(this.buffer,a);else for(var e=0;d>e;e++)this.buffer[a+e]=b[e];this._offset=a-this.byteOffset+d}},setBytes:function(a,b,c){this._setBytes(a,b,defined(c,!0))},getString:function(a,b,c){if(NODE&&this._isNodeBuffer)return b=defined(b,this._offset),a=defined(a,this.byteLength-b),this._checkBounds(b,a),this._offset=b+a,this.buffer.toString(c||"binary",this.byteOffset+b,this.byteOffset+this._offset);var d=this._getBytes(a,b,!0);if(c="utf8"===c?"utf-8":c||"binary",TextDecoder&&"binary"!==c)return new TextDecoder(c).decode(this._isArrayBuffer?d:new Uint8Array(d));var e="";a=d.length;for(var f=0;a>f;f++)e+=String.fromCharCode(d[f]);return"utf-8"===c&&(e=decodeURIComponent(escape(e))),e},setString:function(a,b,c){if(NODE&&this._isNodeBuffer)return a=defined(a,this._offset),this._checkBounds(a,b.length),void(this._offset=a+this.buffer.write(b,this.byteOffset+a,c||"binary"));c="utf8"===c?"utf-8":c||"binary";var d;TextEncoder&&"binary"!==c?d=new TextEncoder(c).encode(b):("utf-8"===c&&(b=unescape(encodeURIComponent(b))),d=getCharCodes(b)),this._setBytes(a,d,!0)},getChar:function(a){return this.getString(1,a)},setChar:function(a,b){this.setString(a,b)},tell:function(){return this._offset},seek:function(a){return this._checkBounds(a,0),this._offset=a},skip:function(a){return this.seek(this._offset+a)},slice:function(a,b,c){function d(a,b){return 0>a?a+b:a}return a=d(a,this.byteLength),b=d(defined(b,this.byteLength),this.byteLength),c?new jDataView(this.getBytes(b-a,a,!0,!0),void 0,void 0,this._littleEndian):new jDataView(this.buffer,this.byteOffset+a,b-a,this._littleEndian)},alignBy:function(a){return this._bitOffset=0,1!==defined(a,1)?this.skip(a-(this._offset%a||a)):this._offset},_getFloat64:function(a,b){var c=this._getBytes(8,a,b),d=1-2*(c[7]>>7),e=((c[7]<<1&255)<<3|c[6]>>4)-1023,f=(15&c[6])*pow2(48)+c[5]*pow2(40)+c[4]*pow2(32)+c[3]*pow2(24)+c[2]*pow2(16)+c[1]*pow2(8)+c[0];return 1024===e?0!==f?0/0:1/0*d:-1023===e?d*f*pow2(-1074):d*(1+f*pow2(-52))*pow2(e)},_getFloat32:function(a,b){var c=this._getBytes(4,a,b),d=1-2*(c[3]>>7),e=(c[3]<<1&255|c[2]>>7)-127,f=(127&c[2])<<16|c[1]<<8|c[0];return 128===e?0!==f?0/0:1/0*d:-127===e?d*f*pow2(-149):d*(1+f*pow2(-23))*pow2(e)},_get64:function(a,b,c){c=defined(c,this._littleEndian),b=defined(b,this._offset);for(var d=c?[0,4]:[4,0],e=0;2>e;e++)d[e]=this.getUint32(b+d[e],c);return this._offset=b+8,new a(d[0],d[1])},getInt64:function(a,b){return this._get64(Int64,a,b)},getUint64:function(a,b){return this._get64(Uint64,a,b)},_getInt32:function(a,b){var c=this._getBytes(4,a,b);return c[3]<<24|c[2]<<16|c[1]<<8|c[0]},_getUint32:function(a,b){return this._getInt32(a,b)>>>0},_getInt16:function(a,b){return this._getUint16(a,b)<<16>>16},_getUint16:function(a,b){var c=this._getBytes(2,a,b);return c[1]<<8|c[0]},_getInt8:function(a){return this._getUint8(a)<<24>>24},_getUint8:function(a){return this._getBytes(1,a)[0]},_getBitRangeData:function(a,b){var c=(defined(b,this._offset)<<3)+this._bitOffset,d=c+a,e=c>>>3,f=d+7>>>3,g=this._getBytes(f-e,e,!0),h=0;(this._bitOffset=7&d)&&(this._bitOffset-=8);for(var i=0,j=g.length;j>i;i++)h=h<<8|g[i];return{start:e,bytes:g,wideValue:h}},getSigned:function(a,b){var c=32-a;return this.getUnsigned(a,b)<>c},getUnsigned:function(a,b){var c=this._getBitRangeData(a,b).wideValue>>>-this._bitOffset;return 32>a?c&~(-1<b?1:0,i=~(-1<b&&(b=-b),0===b?(f=0,g=0):isNaN(b)?(f=2*i+1,g=1):1/0===b?(f=2*i+1,g=0):(f=Math.floor(Math.log(b)/Math.LN2),f>=j&&i>=f?(g=Math.floor((b*pow2(-f)-1)*pow2(c)),f+=i):(g=Math.floor(b/pow2(j-c)),f=0));for(var k=[];c>=8;)k.push(g%256),g=Math.floor(g/256),c-=8;for(f=f<=8;)k.push(255&f),f>>>=8,d-=8;k.push(h<>>8&255,b>>>16&255,b>>>24],c)},_setUint16:function(a,b,c){this._setBytes(a,[255&b,b>>>8&255],c)},_setUint8:function(a,b){this._setBytes(a,[255&b])},setUnsigned:function(a,b,c){var d=this._getBitRangeData(c,a),e=d.wideValue,f=d.bytes;e&=~(~(-1<c?b&~(-1<=0;g--)f[g]=255&e,e>>>=8;this._setBytes(d.start,f,!0)}};if(NODE){var nodeNaming={Int8:"Int8",Int16:"Int16",Int32:"Int32",Uint8:"UInt8",Uint16:"UInt16",Uint32:"UInt32",Float32:"Float",Float64:"Double"};proto._nodeBufferAction=function(a,b,c,d,e){this._offset=c+dataTypes[a];var f=nodeNaming[a]+("Int8"===a||"Uint8"===a?"":d?"LE":"BE");return c+=this.byteOffset,b?this.buffer["read"+f](c):this.buffer["write"+f](e,c)}}for(var type in dataTypes)!function(a){proto["get"+a]=function(b,c){return this._action(a,!0,b,c)},proto["set"+a]=function(b,c,d){this._action(a,!1,b,d,c)}}(type);proto._setInt32=proto._setUint32,proto._setInt16=proto._setUint16,proto._setInt8=proto._setUint8,proto.setSigned=proto.setUnsigned;for(var method in proto)"set"===method.slice(0,3)&&!function(a){proto["write"+a]=function(){Array.prototype.unshift.call(arguments,void 0),this["set"+a].apply(this,arguments)}}(method.slice(3)); \ No newline at end of file +!function(a){var b=this;"object"==typeof exports?module.exports=a(b):"function"==typeof define&&define.amd?define([],function(){return a(b)}):b.jDataView=a(b)}(function(a){"use strict";function b(a,b){return!b&&a instanceof Array?a:Array.prototype.slice.call(a)}function c(a,b){return void 0!==a?a:b}function d(a,b,e,f){if(a instanceof d){var g=a.slice(b,b+e);return g._littleEndian=c(f,g._littleEndian),g}if(!(this instanceof d))return new d(a,b,e,f);if(this.buffer=a=d.wrapBuffer(a),this._isArrayBuffer=i.ArrayBuffer&&a instanceof ArrayBuffer,this._isPixelData=!0&&i.PixelData&&a instanceof CanvasPixelArray,this._isDataView=i.DataView&&this._isArrayBuffer,this._isNodeBuffer=!1,!(this._isArrayBuffer||this._isPixelData||a instanceof Array))throw new TypeError("jDataView buffer has an incompatible type");this._littleEndian=!!f;var h="byteLength"in a?a.byteLength:a.length;this.byteOffset=b=c(b,0),this.byteLength=e=c(e,h-b),this._offset=this._bitOffset=0,this._isDataView?this._view=new DataView(a,b,e):this._checkBounds(b,e,h),this._engineAction=this._isDataView?this._dataViewAction:this._isArrayBuffer?this._arrayBufferAction:this._arrayAction}function e(a){for(var b=i.ArrayBuffer?Uint8Array:Array,c=new b(a.length),d=0,e=a.length;e>d;d++)c[d]=255&a.charCodeAt(d);return c}function f(a){return a>=0&&31>a?1<d;d++)c[d]=b[d];return c};l.context2d=document.createElement("canvas").getContext("2d")}var m={Int8:1,Int16:2,Int32:4,Uint8:1,Uint16:2,Uint32:4,Float32:4,Float64:8};d.wrapBuffer=function(a){switch(typeof a){case"number":if(i.ArrayBuffer)a=new Uint8Array(a).buffer;else if(i.PixelData)a=l(a);else{a=new Array(a);for(var c=0;c=0){var d=g.fromNumber(a);b=d.lo,c=d.hi}else c=Math.floor(a/f(32)),b=a-c*f(32),c+=f(32);return new h(b,c)};var n=d.prototype={compatibility:i,_checkBounds:function(a,b,d){if("number"!=typeof a)throw new TypeError("Offset is not a number.");if("number"!=typeof b)throw new TypeError("Size is not a number.");if(0>b)throw new RangeError("Length is negative.");if(0>a||a+b>c(d,this.byteLength))throw new RangeError("Offsets are out of bounds.")},_action:function(a,b,d,e,f){return this._engineAction(a,b,c(d,this._offset),c(e,this._littleEndian),f)},_dataViewAction:function(a,b,c,d,e){return this._offset=c+m[a],b?this._view["get"+a](c,d):this._view["set"+a](c,e,d)},_arrayBufferAction:function(b,d,e,f,g){var h,i=m[b],j=a[b+"Array"];if(f=c(f,this._littleEndian),1===i||(this.byteOffset+e)%i===0&&f)return h=new j(this.buffer,this.byteOffset+e,1),this._offset=e+i,d?h[0]:h[0]=g;var k=new Uint8Array(d?this.getBytes(i,e,f,!0):i);return h=new j(k.buffer,0,1),d?h[0]:(h[0]=g,void this._setBytes(e,k,f))},_arrayAction:function(a,b,c,d,e){return b?this["_get"+a](c,d):this["_set"+a](c,e,d)},_getBytes:function(a,d,e){e=c(e,this._littleEndian),d=c(d,this._offset),a=c(a,this.byteLength-d),this._checkBounds(d,a),d+=this.byteOffset,this._offset=d-this.byteOffset+a;var f=this._isArrayBuffer?new Uint8Array(this.buffer,d,a):(this.buffer.slice||Array.prototype.slice).call(this.buffer,d,d+a);return e||1>=a?f:b(f).reverse()},getBytes:function(a,d,e,f){var g=this._getBytes(a,d,c(e,!0));return f?b(g):g},_setBytes:function(a,d,e){var f=d.length;if(0!==f){if(e=c(e,this._littleEndian),a=c(a,this._offset),this._checkBounds(a,f),!e&&f>1&&(d=b(d,!0).reverse()),a+=this.byteOffset,this._isArrayBuffer)new Uint8Array(this.buffer,a,f).set(d);else for(var g=0;f>g;g++)this.buffer[a+g]=d[g];this._offset=a-this.byteOffset+f}},setBytes:function(a,b,d){this._setBytes(a,b,c(d,!0))},getString:function(a,b,c){var d=this._getBytes(a,b,!0);if(c="utf8"===c?"utf-8":c||"binary",k&&"binary"!==c)return new k(c).decode(this._isArrayBuffer?d:new Uint8Array(d));var e="";a=d.length;for(var f=0;a>f;f++)e+=String.fromCharCode(d[f]);return"utf-8"===c&&(e=decodeURIComponent(escape(e))),e},setString:function(a,b,c){c="utf8"===c?"utf-8":c||"binary";var d;j&&"binary"!==c?d=new j(c).encode(b):("utf-8"===c&&(b=unescape(encodeURIComponent(b))),d=e(b)),this._setBytes(a,d,!0)},getChar:function(a){return this.getString(1,a)},setChar:function(a,b){this.setString(a,b)},tell:function(){return this._offset},seek:function(a){return this._checkBounds(a,0),this._offset=a},skip:function(a){return this.seek(this._offset+a)},slice:function(a,b,e){function f(a,b){return 0>a?a+b:a}return a=f(a,this.byteLength),b=f(c(b,this.byteLength),this.byteLength),e?new d(this.getBytes(b-a,a,!0,!0),void 0,void 0,this._littleEndian):new d(this.buffer,this.byteOffset+a,b-a,this._littleEndian)},alignBy:function(a){return this._bitOffset=0,1!==c(a,1)?this.skip(a-(this._offset%a||a)):this._offset},_getFloat64:function(a,b){var c=this._getBytes(8,a,b),d=1-2*(c[7]>>7),e=((c[7]<<1&255)<<3|c[6]>>4)-1023,g=(15&c[6])*f(48)+c[5]*f(40)+c[4]*f(32)+c[3]*f(24)+c[2]*f(16)+c[1]*f(8)+c[0];return 1024===e?0!==g?0/0:1/0*d:-1023===e?d*g*f(-1074):d*(1+g*f(-52))*f(e)},_getFloat32:function(a,b){var c=this._getBytes(4,a,b),d=1-2*(c[3]>>7),e=(c[3]<<1&255|c[2]>>7)-127,g=(127&c[2])<<16|c[1]<<8|c[0];return 128===e?0!==g?0/0:1/0*d:-127===e?d*g*f(-149):d*(1+g*f(-23))*f(e)},_get64:function(a,b,d){d=c(d,this._littleEndian),b=c(b,this._offset);for(var e=d?[0,4]:[4,0],f=0;2>f;f++)e[f]=this.getUint32(b+e[f],d);return this._offset=b+8,new a(e[0],e[1])},getInt64:function(a,b){return this._get64(h,a,b)},getUint64:function(a,b){return this._get64(g,a,b)},_getInt32:function(a,b){var c=this._getBytes(4,a,b);return c[3]<<24|c[2]<<16|c[1]<<8|c[0]},_getUint32:function(a,b){return this._getInt32(a,b)>>>0},_getInt16:function(a,b){return this._getUint16(a,b)<<16>>16},_getUint16:function(a,b){var c=this._getBytes(2,a,b);return c[1]<<8|c[0]},_getInt8:function(a){return this._getUint8(a)<<24>>24},_getUint8:function(a){return this._getBytes(1,a)[0]},_getBitRangeData:function(a,b){var d=(c(b,this._offset)<<3)+this._bitOffset,e=d+a,f=d>>>3,g=e+7>>>3,h=this._getBytes(g-f,f,!0),i=0;(this._bitOffset=7&e)&&(this._bitOffset-=8);for(var j=0,k=h.length;k>j;j++)i=i<<8|h[j];return{start:f,bytes:h,wideValue:i}},getSigned:function(a,b){var c=32-a;return this.getUnsigned(a,b)<>c},getUnsigned:function(a,b){var c=this._getBitRangeData(a,b).wideValue>>>-this._bitOffset;return 32>a?c&~(-1<b?1:0,j=~(-1<b&&(b=-b),0===b?(g=0,h=0):isNaN(b)?(g=2*j+1,h=1):1/0===b?(g=2*j+1,h=0):(g=Math.floor(Math.log(b)/Math.LN2),g>=k&&j>=g?(h=Math.floor((b*f(-g)-1)*f(c)),g+=j):(h=Math.floor(b/f(k-c)),g=0));for(var l=[];c>=8;)l.push(h%256),h=Math.floor(h/256),c-=8;for(g=g<=8;)l.push(255&g),g>>>=8,d-=8;l.push(i<>>8&255,b>>>16&255,b>>>24],c)},_setUint16:function(a,b,c){this._setBytes(a,[255&b,b>>>8&255],c)},_setUint8:function(a,b){this._setBytes(a,[255&b])},setUnsigned:function(a,b,c){var d=this._getBitRangeData(c,a),e=d.wideValue,f=d.bytes;e&=~(~(-1<c?b&~(-1<=0;g--)f[g]=255&e,e>>>=8;this._setBytes(d.start,f,!0)}};for(var o in m)!function(a){n["get"+a]=function(b,c){return this._action(a,!0,b,c)},n["set"+a]=function(b,c,d){this._action(a,!1,b,d,c)}}(o);n._setInt32=n._setUint32,n._setInt16=n._setUint16,n._setInt8=n._setUint8,n.setSigned=n.setUnsigned;for(var p in n)"set"===p.slice(0,3)&&!function(a){n["write"+a]=function(){Array.prototype.unshift.call(arguments,void 0),this["set"+a].apply(this,arguments)}}(p.slice(3));return d}); +//# sourceMappingURL=jdataview.js.map \ No newline at end of file diff --git a/build/wampy-all.min.js b/build/wampy-all.min.js index 7563ef9..4aed406 100644 --- a/build/wampy-all.min.js +++ b/build/wampy-all.min.js @@ -1,2 +1,19 @@ -function arrayFrom(a,b){return!b&&a instanceof Array?a:Array.prototype.slice.call(a)}function defined(a,b){return void 0!==a?a:b}function jDataView(a,b,c,d){if(a instanceof jDataView){var e=a.slice(b,b+c);return e._littleEndian=defined(d,e._littleEndian),e}if(!(this instanceof jDataView))return new jDataView(a,b,c,d);if(this.buffer=a=jDataView.wrapBuffer(a),this._isArrayBuffer=compatibility.ArrayBuffer&&a instanceof ArrayBuffer,this._isPixelData=BROWSER&&compatibility.PixelData&&a instanceof CanvasPixelArray,this._isDataView=compatibility.DataView&&this._isArrayBuffer,this._isNodeBuffer=NODE&&compatibility.NodeBuffer&&a instanceof Buffer,!(NODE&&this._isNodeBuffer||this._isArrayBuffer||BROWSER&&this._isPixelData||a instanceof Array))throw new TypeError("jDataView buffer has an incompatible type");this._littleEndian=!!d;var f="byteLength"in a?a.byteLength:a.length;this.byteOffset=b=defined(b,0),this.byteLength=c=defined(c,f-b),this._offset=this._bitOffset=0,this._isDataView?this._view=new DataView(a,b,c):this._checkBounds(b,c,f),this._engineAction=this._isDataView?this._dataViewAction:NODE&&this._isNodeBuffer?this._nodeBufferAction:this._isArrayBuffer?this._arrayBufferAction:this._arrayAction}function getCharCodes(a){if(NODE&&compatibility.NodeBuffer)return new Buffer(a,"binary");for(var b=compatibility.ArrayBuffer?Uint8Array:Array,c=new b(a.length),d=0,e=a.length;e>d;d++)c[d]=255&a.charCodeAt(d);return c}function pow2(a){return a>=0&&31>a?1<d;d++)c[d]=b[d];return c};createPixelData.context2d=document.createElement("canvas").getContext("2d")}var dataTypes={Int8:1,Int16:2,Int32:4,Uint8:1,Uint16:2,Uint32:4,Float32:4,Float64:8};jDataView.wrapBuffer=function(a){switch(typeof a){case"number":if(NODE&&compatibility.NodeBuffer)a=new Buffer(a),a.fill(0);else if(compatibility.ArrayBuffer)a=new Uint8Array(a).buffer;else if(BROWSER&&compatibility.PixelData)a=createPixelData(a);else{a=new Array(a);for(var b=0;b=0){var d=Uint64.fromNumber(a);b=d.lo,c=d.hi}else c=Math.floor(a/pow2(32)),b=a-c*pow2(32),c+=pow2(32);return new Int64(b,c)};var proto=jDataView.prototype={compatibility:compatibility,_checkBounds:function(a,b,c){if("number"!=typeof a)throw new TypeError("Offset is not a number.");if("number"!=typeof b)throw new TypeError("Size is not a number.");if(0>b)throw new RangeError("Length is negative.");if(0>a||a+b>defined(c,this.byteLength))throw new RangeError("Offsets are out of bounds.")},_action:function(a,b,c,d,e){return this._engineAction(a,b,defined(c,this._offset),defined(d,this._littleEndian),e)},_dataViewAction:function(a,b,c,d,e){return this._offset=c+dataTypes[a],b?this._view["get"+a](c,d):this._view["set"+a](c,e,d)},_arrayBufferAction:function(a,b,c,d,e){var f,g=dataTypes[a],h=global[a+"Array"];if(d=defined(d,this._littleEndian),1===g||(this.byteOffset+c)%g===0&&d)return f=new h(this.buffer,this.byteOffset+c,1),this._offset=c+g,b?f[0]:f[0]=e;var i=new Uint8Array(b?this.getBytes(g,c,d,!0):g);return f=new h(i.buffer,0,1),b?f[0]:(f[0]=e,void this._setBytes(c,i,d))},_arrayAction:function(a,b,c,d,e){return b?this["_get"+a](c,d):this["_set"+a](c,e,d)},_getBytes:function(a,b,c){c=defined(c,this._littleEndian),b=defined(b,this._offset),a=defined(a,this.byteLength-b),this._checkBounds(b,a),b+=this.byteOffset,this._offset=b-this.byteOffset+a;var d=this._isArrayBuffer?new Uint8Array(this.buffer,b,a):(this.buffer.slice||Array.prototype.slice).call(this.buffer,b,b+a);return c||1>=a?d:arrayFrom(d).reverse()},getBytes:function(a,b,c,d){var e=this._getBytes(a,b,defined(c,!0));return d?arrayFrom(e):e},_setBytes:function(a,b,c){var d=b.length;if(0!==d){if(c=defined(c,this._littleEndian),a=defined(a,this._offset),this._checkBounds(a,d),!c&&d>1&&(b=arrayFrom(b,!0).reverse()),a+=this.byteOffset,this._isArrayBuffer)new Uint8Array(this.buffer,a,d).set(b);else if(NODE&&this._isNodeBuffer)new Buffer(b).copy(this.buffer,a);else for(var e=0;d>e;e++)this.buffer[a+e]=b[e];this._offset=a-this.byteOffset+d}},setBytes:function(a,b,c){this._setBytes(a,b,defined(c,!0))},getString:function(a,b,c){if(NODE&&this._isNodeBuffer)return b=defined(b,this._offset),a=defined(a,this.byteLength-b),this._checkBounds(b,a),this._offset=b+a,this.buffer.toString(c||"binary",this.byteOffset+b,this.byteOffset+this._offset);var d=this._getBytes(a,b,!0);if(c="utf8"===c?"utf-8":c||"binary",TextDecoder&&"binary"!==c)return new TextDecoder(c).decode(this._isArrayBuffer?d:new Uint8Array(d));var e="";a=d.length;for(var f=0;a>f;f++)e+=String.fromCharCode(d[f]);return"utf-8"===c&&(e=decodeURIComponent(escape(e))),e},setString:function(a,b,c){if(NODE&&this._isNodeBuffer)return a=defined(a,this._offset),this._checkBounds(a,b.length),void(this._offset=a+this.buffer.write(b,this.byteOffset+a,c||"binary"));c="utf8"===c?"utf-8":c||"binary";var d;TextEncoder&&"binary"!==c?d=new TextEncoder(c).encode(b):("utf-8"===c&&(b=unescape(encodeURIComponent(b))),d=getCharCodes(b)),this._setBytes(a,d,!0)},getChar:function(a){return this.getString(1,a)},setChar:function(a,b){this.setString(a,b)},tell:function(){return this._offset},seek:function(a){return this._checkBounds(a,0),this._offset=a},skip:function(a){return this.seek(this._offset+a)},slice:function(a,b,c){function d(a,b){return 0>a?a+b:a}return a=d(a,this.byteLength),b=d(defined(b,this.byteLength),this.byteLength),c?new jDataView(this.getBytes(b-a,a,!0,!0),void 0,void 0,this._littleEndian):new jDataView(this.buffer,this.byteOffset+a,b-a,this._littleEndian)},alignBy:function(a){return this._bitOffset=0,1!==defined(a,1)?this.skip(a-(this._offset%a||a)):this._offset},_getFloat64:function(a,b){var c=this._getBytes(8,a,b),d=1-2*(c[7]>>7),e=((c[7]<<1&255)<<3|c[6]>>4)-1023,f=(15&c[6])*pow2(48)+c[5]*pow2(40)+c[4]*pow2(32)+c[3]*pow2(24)+c[2]*pow2(16)+c[1]*pow2(8)+c[0];return 1024===e?0!==f?0/0:1/0*d:-1023===e?d*f*pow2(-1074):d*(1+f*pow2(-52))*pow2(e)},_getFloat32:function(a,b){var c=this._getBytes(4,a,b),d=1-2*(c[3]>>7),e=(c[3]<<1&255|c[2]>>7)-127,f=(127&c[2])<<16|c[1]<<8|c[0];return 128===e?0!==f?0/0:1/0*d:-127===e?d*f*pow2(-149):d*(1+f*pow2(-23))*pow2(e)},_get64:function(a,b,c){c=defined(c,this._littleEndian),b=defined(b,this._offset);for(var d=c?[0,4]:[4,0],e=0;2>e;e++)d[e]=this.getUint32(b+d[e],c);return this._offset=b+8,new a(d[0],d[1])},getInt64:function(a,b){return this._get64(Int64,a,b)},getUint64:function(a,b){return this._get64(Uint64,a,b)},_getInt32:function(a,b){var c=this._getBytes(4,a,b);return c[3]<<24|c[2]<<16|c[1]<<8|c[0]},_getUint32:function(a,b){return this._getInt32(a,b)>>>0},_getInt16:function(a,b){return this._getUint16(a,b)<<16>>16},_getUint16:function(a,b){var c=this._getBytes(2,a,b);return c[1]<<8|c[0]},_getInt8:function(a){return this._getUint8(a)<<24>>24},_getUint8:function(a){return this._getBytes(1,a)[0]},_getBitRangeData:function(a,b){var c=(defined(b,this._offset)<<3)+this._bitOffset,d=c+a,e=c>>>3,f=d+7>>>3,g=this._getBytes(f-e,e,!0),h=0;(this._bitOffset=7&d)&&(this._bitOffset-=8);for(var i=0,j=g.length;j>i;i++)h=h<<8|g[i];return{start:e,bytes:g,wideValue:h}},getSigned:function(a,b){var c=32-a;return this.getUnsigned(a,b)<>c},getUnsigned:function(a,b){var c=this._getBitRangeData(a,b).wideValue>>>-this._bitOffset;return 32>a?c&~(-1<b?1:0,i=~(-1<b&&(b=-b),0===b?(f=0,g=0):isNaN(b)?(f=2*i+1,g=1):1/0===b?(f=2*i+1,g=0):(f=Math.floor(Math.log(b)/Math.LN2),f>=j&&i>=f?(g=Math.floor((b*pow2(-f)-1)*pow2(c)),f+=i):(g=Math.floor(b/pow2(j-c)),f=0));for(var k=[];c>=8;)k.push(g%256),g=Math.floor(g/256),c-=8;for(f=f<=8;)k.push(255&f),f>>>=8,d-=8;k.push(h<>>8&255,b>>>16&255,b>>>24],c)},_setUint16:function(a,b,c){this._setBytes(a,[255&b,b>>>8&255],c)},_setUint8:function(a,b){this._setBytes(a,[255&b])},setUnsigned:function(a,b,c){var d=this._getBitRangeData(c,a),e=d.wideValue,f=d.bytes;e&=~(~(-1<c?b&~(-1<=0;g--)f[g]=255&e,e>>>=8;this._setBytes(d.start,f,!0)}};if(NODE){var nodeNaming={Int8:"Int8",Int16:"Int16",Int32:"Int32",Uint8:"UInt8",Uint16:"UInt16",Uint32:"UInt32",Float32:"Float",Float64:"Double"};proto._nodeBufferAction=function(a,b,c,d,e){this._offset=c+dataTypes[a];var f=nodeNaming[a]+("Int8"===a||"Uint8"===a?"":d?"LE":"BE");return c+=this.byteOffset,b?this.buffer["read"+f](c):this.buffer["write"+f](e,c)}}for(var type in dataTypes)!function(a){proto["get"+a]=function(b,c){return this._action(a,!0,b,c)},proto["set"+a]=function(b,c,d){this._action(a,!1,b,d,c)}}(type);proto._setInt32=proto._setUint32,proto._setInt16=proto._setUint16,proto._setInt8=proto._setUint8,proto.setSigned=proto.setUnsigned;for(var method in proto)"set"===method.slice(0,3)&&!function(a){proto["write"+a]=function(){Array.prototype.unshift.call(arguments,void 0),this["set"+a].apply(this,arguments)}}(method.slice(3));("function"==typeof define?function(a){define("msgpack-js",a)}:"object"==typeof exports?function(a){module.exports=a()}:function(a){this.msgpack=a()})(function(){"use strict";function a(a){if(void 0===a)return"undefined";var b,c;if(a instanceof ArrayBuffer?(c="ArrayBuffer",b=new DataView(a)):a instanceof DataView&&(c="DataView",b=a),!b)return JSON.stringify(a);for(var d=[],e=0;e20){d.push("...");break}var f=b.getUint8(e).toString(16);1===f.length&&(f="0"+f),d.push(f)}return"<"+c+" "+d.join(" ")+">"}function b(a,b,c){for(var d=(a.byteLength,0),e=c.length;e>d;d++){var f=c.charCodeAt(d);if(128>f)a.setUint8(b++,f>>>0&127|0);else if(2048>f)a.setUint8(b++,f>>>6&31|192),a.setUint8(b++,f>>>0&63|128);else if(65536>f)a.setUint8(b++,f>>>12&15|224),a.setUint8(b++,f>>>6&63|128),a.setUint8(b++,f>>>0&63|128);else{if(!(1114112>f))throw new Error("bad codepoint "+f);a.setUint8(b++,f>>>18&7|240),a.setUint8(b++,f>>>12&63|128),a.setUint8(b++,f>>>6&63|128),a.setUint8(b++,f>>>0&63|128)}}}function c(a,b,c){for(var d="",e=b,f=b+c;f>e;e++){var g=a.getUint8(e);if(0!==(128&g))if(192!==(224&g))if(224!==(240&g)){if(240!==(248&g))throw new Error("Invalid byte "+g.toString(16));d+=String.fromCharCode((7&g)<<18|(63&a.getUint8(++e))<<12|(63&a.getUint8(++e))<<6|(63&a.getUint8(++e))<<0)}else d+=String.fromCharCode((15&g)<<12|(63&a.getUint8(++e))<<6|(63&a.getUint8(++e))<<0);else d+=String.fromCharCode((15&g)<<6|63&a.getUint8(++e));else d+=String.fromCharCode(g)}return d}function d(a){for(var b=0,c=0,d=a.length;d>c;c++){var e=a.charCodeAt(c);if(128>e)b+=1;else if(2048>e)b+=2;else if(65536>e)b+=3;else{if(!(1114112>e))throw new Error("bad codepoint "+e);b+=4}}return b}function e(a,b){this.offset=b||0,this.view=a}function f(a){var b=new jDataView(a),c=new e(b),d=c.parse();if(c.offset!==a.byteLength)throw new Error(a.byteLength-c.offset+" trailing bytes");return d}function g(a,c,e){var f,h,i,j,k=typeof a;if("string"===k){if(f=d(a),32>f)return c.setUint8(e,160|f),b(c,e+1,a),1+f;if(256>f)return c.setUint8(e,217),c.setUint16(e+1,f),b(c,e+2,a),2+f;if(65536>f)return c.setUint8(e,218),c.setUint16(e+1,f),b(c,e+3,a),3+f;if(4294967296>f)return c.setUint8(e,219),c.setUint32(e+1,f),b(c,e+5,a),5+f}if(a instanceof ArrayBuffer){if(f=a.byteLength,256>f)return c.setUint8(e,196),c.setUint16(e+1,f),new Uint8Array(c.buffer).set(new Uint8Array(a),e+2),2+f;if(65536>f)return c.setUint8(e,216),c.setUint16(e+1,f),new Uint8Array(c.buffer).set(new Uint8Array(a),e+3),3+f;if(4294967296>f)return c.setUint8(e,217),c.setUint32(e+1,f),new Uint8Array(c.buffer).set(new Uint8Array(a),e+5),5+f}if("number"===k){if(a%1!==0)return c.setUint8(e,203),c.setFloat64(e+1,a),9;if(a>=0){if(128>a)return c.setUint8(e,a),1;if(256>a)return c.setUint8(e,204),c.setUint8(e+1,a),2;if(65536>a)return c.setUint8(e,205),c.setUint16(e+1,a),3;if(4294967296>a)return c.setUint8(e,206),c.setUint32(e+1,a),5;if(0x10000000000000000>a)return c.setUint8(e,207),c.setUint64(e+1,a),9;throw new Error("Number too big 0x"+a.toString(16))}if(a>=-32)return c.setInt8(e,a),1;if(a>=-128)return c.setUint8(e,208),c.setInt8(e+1,a),2;if(a>=-32768)return c.setUint8(e,209),c.setInt16(e+1,a),3;if(a>=-2147483648)return c.setUint8(e,210),c.setInt32(e+1,a),5;if(a>=-2147483648)return c.setUint8(e,211),c.setUint64(e+1,a),9;throw new Error("Number too small -0x"+(-a).toString(16).substr(1))}if("undefined"===k)return c.setUint8(e,212),c.setUint8(e+1,0),c.setUint8(e+2,0),1;if(null===a)return c.setUint8(e,192),1;if("boolean"===k)return c.setUint8(e,a?195:194),1;if("function"==typeof a.toJSON)return g(a.toJSON(),c,e);if("object"===k){if(h=0,i=Array.isArray(a))f=a.length;else{var l=Object.keys(a);f=l.length}if(16>f?(c.setUint8(e,f|(i?144:128)),h=1):65536>f?(c.setUint8(e,i?220:222),c.setUint16(e+1,f),h=3):4294967296>f&&(c.setUint8(e,i?221:223),c.setUint32(e+1,f),h=5),i)for(j=0;f>j;j++)h+=g(a[j],c,e+h);else for(j=0;f>j;j++){var m=l[j];h+=g(m,c,e+h),h+=g(a[m],c,e+h)}return h}throw new Error("Unknown type "+k)}function h(a){var b,c,e,f,g=typeof a;if("string"===g){if(b=d(a),32>b)return 1+b;if(256>b)return 2+b;if(65536>b)return 3+b;if(4294967296>b)return 5+b}if(a instanceof ArrayBuffer){if(b=a.byteLength,256>b)return 2+b;if(65536>b)return 3+b;if(4294967296>b)return 5+b}if("number"===g){if(a<<0!==a)return 9;if(a>=0){if(128>a)return 1;if(256>a)return 2;if(65536>a)return 3;if(4294967296>a)return 5;if(0x10000000000000000>a)return 9;throw new Error("Number too big 0x"+a.toString(16))}if(a>=-32)return 1;if(a>=-128)return 2;if(a>=-32768)return 3;if(a>=-2147483648)return 5;if(a>=-0x8000000000000000)return 9;throw new Error("Number too small -0x"+a.toString(16).substr(1))}if("boolean"===g||null===a)return 1;if("undefined"===g)return 3;if("function"==typeof a.toJSON)return h(a.toJSON());if("object"===g){if("function"==typeof a.toJSON&&(a=a.toJSON()),c=0,Array.isArray(a))for(b=a.length,f=0;b>f;f++)c+=h(a[f]);else for(e=Object.keys(a),b=e.length,f=0;b>f;f++)c+=h(e[f])+h(a[e[f]]);if(16>b)return 1+c;if(65536>b)return 3+c;if(4294967296>b)return 5+c;throw new Error("Array or object too long 0x"+b.toString(16))}if("function"===g)return 0;throw new Error("Unknown type "+g)}var i={};return i.inspect=a,i.utf8Write=b,i.utf8Read=c,i.utf8ByteCount=d,i.encode=function(a){var b=new ArrayBuffer(h(a)),c=new jDataView(b);return g(a,c,0),b},i.decode=f,e.prototype.map=function(a){for(var b={},c=0;a>c;c++){var d=this.parse();b[d]=this.parse()}return b},e.prototype.buf=function(a){var b=new ArrayBuffer(a);return new Uint8Array(b).set(new Uint8Array(this.view.buffer,this.offset,a),0),this.offset+=a,b},e.prototype.u8str=function(a){var b=c(this.view,this.offset,a);return this.offset+=a,b},e.prototype.array=function(a){for(var b=new Array(a),c=0;a>c;c++)b[c]=this.parse();return b},e.prototype.parse=function(){var a,b,c,d=this.view.getUint8(this.offset);if(0===(128&d))return this.offset++,d;if(128===(240&d))return b=15&d,this.offset++,this.map(b);if(144===(240&d))return b=15&d,this.offset++,this.array(b);if(160===(224&d))return b=31&d,this.offset++,this.u8str(b);if(224===(224&d))return a=this.view.getInt8(this.offset),this.offset++,a;switch(d){case 192:return this.offset++,null;case 194:return this.offset++,!1;case 195:return this.offset++,!0;case 196:return b=this.view.getUint8(this.offset+1),this.offset+=2,this.buf(b);case 197:return b=this.view.getUint16(this.offset+1),this.offset+=3,this.buf(b);case 198:return b=this.view.getUint32(this.offset+1),this.offset+=5,this.buf(b);case 199:return b=this.view.getUint8(this.offset+1),c=this.view.getUint8(this.offset+2),this.offset+=3,[c,this.buf(b)];case 200:return b=this.view.getUint16(this.offset+1),c=this.view.getUint8(this.offset+3),this.offset+=4,[c,this.buf(b)];case 201:return b=this.view.getUint32(this.offset+1),c=this.view.getUint8(this.offset+5),this.offset+=6,[c,this.buf(b)];case 202:return a=this.view.getFloat32(this.offset+1),this.offset+=5,a;case 203:return a=this.view.getFloat64(this.offset+1),this.offset+=9,a;case 204:return a=this.view.getUint8(this.offset+1),this.offset+=2,a;case 205:return a=this.view.getUint16(this.offset+1),this.offset+=3,a;case 206:return a=this.view.getUint32(this.offset+1),this.offset+=5,a;case 207:return a=this.view.getUint64(this.offset+1),this.offset+=9,parseInt(a);case 208:return a=this.view.getInt8(this.offset+1),this.offset+=2,a;case 209:return a=this.view.getInt16(this.offset+1),this.offset+=3,a;case 210:return a=this.view.getInt32(this.offset+1),this.offset+=5,a;case 211:return a=this.view.getInt64(this.offset+1),this.offset+=9,parseInt(a);case 212:return c=this.view.getUint8(this.offset+1),a=this.view.getUint8(this.offset+2),this.offset+=3,0===c&&0===a?void 0:[c,a];case 213:return c=this.view.getUint8(this.offset+1),this.offset+=2,[c,this.buf(2)];case 214:return c=this.view.getUint8(this.offset+1),this.offset+=2,[c,this.buf(4)];case 215:return c=this.view.getUint8(this.offset+1),this.offset+=2,[c,this.buf(8)];case 216:return c=this.view.getUint8(this.offset+1),this.offset+=2,[c,this.buf(16)];case 217:return b=this.view.getUint8(this.offset+1),this.offset+=2,this.u8str(b);case 218:return b=this.view.getUint16(this.offset+1),this.offset+=3,this.u8str(b);case 219:return b=this.view.getUint32(this.offset+1),this.offset+=5,this.u8str(b);case 220:return b=this.view.getUint16(this.offset+1),this.offset+=3,this.array(b);case 221:return b=this.view.getUint32(this.offset+1),this.offset+=5,this.array(b);case 222:return b=this.view.getUint16(this.offset+1),this.offset+=3,this.map(b);case 223:return b=this.view.getUint32(this.offset+1),this.offset+=5,this.map(b)}throw new Error("Unknown type 0x"+d.toString(16))},i}),("function"==typeof define?function(a){define("Wampy",a)}:"object"==typeof exports?function(a){module.exports=a()}:function(a){this.Wampy=a()})(function(){function a(a){var b,c,d;return a?/^ws/.test(a)?a:/:\d{1,5}/.test(a)?(b="https:"===window.location.protocol?"wss://":"ws://",b+a):(b="https:"===window.location.protocol?"wss://":"ws://",c=""!==window.location.port?":"+window.location.port:"",d="/"===a[0]?a:"/"+a,b+window.location.hostname+c+d):(b="https:"===window.location.protocol?"wss://":"ws://",c=""!==window.location.port?":"+window.location.port:"",b+window.location.hostname+c+"/ws")}function b(b,c){var d=a(b);return"WebSocket"in window?c?new WebSocket(d,c):new WebSocket(d):"MozWebSocket"in window?c?new MozWebSocket(d,c):new MozWebSocket(d):null}var c={HELLO:1,WELCOME:2,ABORT:3,CHALLENGE:4,AUTHENTICATE:5,GOODBYE:6,HEARTBEAT:7,ERROR:8,PUBLISH:16,PUBLISHED:17,SUBSCRIBE:32,SUBSCRIBED:33,UNSUBSCRIBE:34,UNSUBSCRIBED:35,EVENT:36,CALL:48,CANCEL:49,RESULT:50,REGISTER:64,REGISTERED:65,UNREGISTER:66,UNREGISTERED:67,INVOCATION:68,INTERRUPT:69,YIELD:70},d={SUCCESS:{code:0,description:"Success!"},URI_ERROR:{code:1,description:"Topic URI doesn't meet requirements!"},NO_BROKER:{code:2,description:"Server doesn't provide broker role!"},NO_CALLBACK_SPEC:{code:3,description:"No required callback function specified!"},INVALID_PARAM:{code:4,description:"Invalid parameter(s) specified!"},NON_EXIST_SUBSCRIBE_CONFIRM:{code:5,description:"Received subscribe confirmation to non existent subscription!"},NON_EXIST_SUBSCRIBE_ERROR:{code:6,description:"Received error for non existent subscription!"},NON_EXIST_UNSUBSCRIBE:{code:7,description:"Trying to unsubscribe from non existent subscription!"},NON_EXIST_SUBSCRIBE_UNSUBSCRIBED:{code:8,description:"Received unsubscribe confirmation to non existent subscription!"},NON_EXIST_PUBLISH_ERROR:{code:9,description:"Received error for non existent publication!"},NON_EXIST_PUBLISH_PUBLISHED:{code:10,description:"Received publish confirmation for non existent publication!"},NON_EXIST_SUBSCRIBE_EVENT:{code:11,description:"Received event for non existent subscription!"},NO_DEALER:{code:12,description:"Server doesn't provide dealer role!"},NON_EXIST_CALL_RESULT:{code:13,description:"Received rpc result for non existent call!"},NON_EXIST_CALL_ERROR:{code:14,description:"Received rpc call error for non existent call!"},RPC_ALREADY_REGISTERED:{code:15,description:"RPC already registered!"},NON_EXIST_RPC_REG:{code:16,description:"Received rpc registration confirmation for non existent rpc!"},NON_EXIST_RPC_UNREG:{code:17,description:"Received rpc unregistration confirmation for non existent rpc!"},NON_EXIST_RPC_ERROR:{code:18,description:"Received error for non existent rpc!"},NON_EXIST_RPC_INVOCATION:{code:19,description:"Received invocation for non existent rpc!"}},e=function(a,c){switch(this.version="v1.0.4",this._url="string"==typeof arguments[0]?a:void 0,this._protocols=["wamp.2.json"],this._wamp_features={agent:"Wampy.js "+this.version,roles:{publisher:{features:{subscriber_blackwhite_listing:!0,publisher_exclusion:!0,publisher_identification:!0}},subscriber:{},caller:{features:{callee_blackwhite_listing:!0,caller_exclusion:!0,caller_identification:!0}},callee:{features:{caller_identification:!0}}}},this._cache={sessionId:null,server_wamp_features:{roles:{}},isSayingGoodbye:!1,opStatus:{code:0,description:"Success!"},timer:null,reconnectingAttempts:0},this._ws=null,this._wsQueue=[],this._requests={},this._calls={},this._subscriptions={},this._subsTopics=[],this._rpcRegs={},this._rpcNames=[],this._options={autoReconnect:!0,reconnectInterval:2e3,maxRetries:25,transportEncoding:"json",realm:window.location.hostname,onConnect:null,onClose:null,onError:null,onReconnect:null},arguments.length){case 1:"string"!=typeof arguments[0]&&(this._options=this._merge(this._options,arguments[0]));break;case 2:this._options=this._merge(this._options,c)}this._setWsProtocols(),this._ws=b(this._url,this._protocols),this._initWsCallbacks()};return e.prototype._getReqId=function(){var a;do a=Math.floor(1e14*Math.random());while(a in this._requests);return a},e.prototype._merge=function(){var a,b,c={},d=arguments.length;for(a=0;d>a;a++)for(b in arguments[a])c[b]=arguments[a][b];return c},e.prototype._isArray=function(a){return!!a&&a.constructor===Array},e.prototype._isObject=function(a){return a===Object(a)&&"[object Array]"!==Object.prototype.toString.call(a)},e.prototype._isPlainObject=function(a){return!!a&&a.constructor===Object},e.prototype._setWsProtocols=function(){void 0!==window.msgpack&&(this._protocols="msgpack"===this._options.transportEncoding?["wamp.2.msgpack","wamp.2.json"]:["wamp.2.json","wamp.2.msgpack"])},e.prototype._validateURI=function(a){var b=/^([0-9a-z_]{2,}\.)*([0-9a-z_]{2,})$/;return b.test(a)&&0!==a.indexOf("wamp")?!0:!1},e.prototype._encode=function(a){var b;if("msgpack"!==this._options.transportEncoding)return JSON.stringify(a);try{return b=new Uint8Array(msgpack.encode(a)),b.buffer}catch(c){throw new Error("[wampy] no msgpack encoder available!")}},e.prototype._decode=function(a){if("msgpack"!==this._options.transportEncoding)return JSON.parse(a);try{return msgpack.decode(a)}catch(b){throw new Error("[wampy] no msgpack encoder available!")}},e.prototype._send=function(a){if(a&&this._wsQueue.push(this._encode(a)),1===this._ws.readyState&&this._cache.sessionId)for(;this._wsQueue.length;)this._ws.send(this._wsQueue.shift())},e.prototype._resetState=function(){this._wsQueue=[],this._subscriptions={},this._subsTopics=[],this._requests={},this._calls={},this._rpcRegs={},this._rpcNames=[],this._cache={reconnectingAttempts:0}},e.prototype._initWsCallbacks=function(){var a=this;this._ws.onopen=function(){a._wsOnOpen.call(a)},this._ws.onclose=function(b){a._wsOnClose.call(a,b)},this._ws.onmessage=function(b){a._wsOnMessage.call(a,b)},this._ws.onerror=function(b){a._wsOnError.call(a,b)}},e.prototype._wsOnOpen=function(){var a;a=this._ws.protocol.split("."),this._options.transportEncoding=a[2],"msgpack"===this._options.transportEncoding&&(this._ws.binaryType="arraybuffer"),this._ws.send(this._encode([c.HELLO,this._options.realm,this._wamp_features]))},e.prototype._wsOnClose=function(){var a=this;(this._cache.sessionId||this._cache.reconnectingAttempts)&&this._options.autoReconnect&&this._cache.reconnectingAttempts=0&&this._subsTopics.splice(f,1),this._requests[b[1]].callbacks.onSuccess&&this._requests[b[1]].callbacks.onSuccess(),delete this._requests[b[1]]):this._cache.opStatus=d.NON_EXIST_SUBSCRIBE_UNSUBSCRIBED;break;case c.PUBLISHED:this._requests[b[1]]?(this._requests[b[1]].callbacks.onSuccess&&this._requests[b[1]].callbacks.onSuccess(),delete this._requests[b[1]]):this._cache.opStatus=d.NON_EXIST_PUBLISH_PUBLISHED;break;case c.EVENT:if(this._subscriptions[b[1]]){switch(b.length){case 4:g=null;break;case 5:g=b[4];break;case 6:g=b[5]}for(f=this._subscriptions[b[1]].callbacks.length;f--;)this._subscriptions[b[1]].callbacks[f](g)}else this._cache.opStatus=d.NON_EXIST_SUBSCRIBE_EVENT;break;case c.RESULT:if(this._calls[b[1]]){switch(b.length){case 3:g=null;break;case 4:g=b[3];break;case 5:g=b[4]}this._calls[b[1]].onSuccess(g),delete this._calls[b[1]]}else this._cache.opStatus=d.NON_EXIST_CALL_RESULT;break;case c.REGISTER:break;case c.REGISTERED:this._requests[b[1]]?(this._rpcRegs[this._requests[b[1]].topic]=this._rpcRegs[b[2]]={id:b[2],callbacks:[this._requests[b[1]].callbacks.rpc]},this._rpcNames.push(this._requests[b[1]].topic),this._requests[b[1]].callbacks.onSuccess&&this._requests[b[1]].callbacks.onSuccess(),delete this._requests[b[1]]):this._cache.opStatus=d.NON_EXIST_RPC_REG;break;case c.UNREGISTER:break;case c.UNREGISTERED:this._requests[b[1]]?(e=this._rpcRegs[this._requests[b[1]].topic].id,delete this._rpcRegs[this._requests[b[1]].topic],delete this._rpcRegs[e],f=this._rpcNames.indexOf(this._requests[b[1]].topic),f>=0&&this._rpcNames.splice(f,1),this._requests[b[1]].callbacks.onSuccess&&this._requests[b[1]].callbacks.onSuccess(),delete this._requests[b[1]]):this._cache.opStatus=d.NON_EXIST_RPC_UNREG;break;case c.INVOCATION:if(this._rpcRegs[b[2]]){switch(b.length){case 4:g=null;break;case 5:g=b[4];break;case 6:g=b[5]}try{h=this._rpcRegs[b[2]].callbacks[0](g)}catch(j){return void this._send([c.ERROR,c.INVOCATION,b[1],{},"wamp.error.invocation_exception"])}i=this._isArray(h)?[c.YIELD,b[1],{},h]:this._isPlainObject(h)?[c.YIELD,b[1],{},[],h]:void 0===h?[c.YIELD,b[1],{}]:[c.YIELD,b[1],{},[h]],this._send(i)}else this._send([c.ERROR,c.INVOCATION,b[1],{},"wamp.error.no_such_procedure"]),this._cache.opStatus=d.NON_EXIST_RPC_INVOCATION;break;case c.INTERRUPT:break;case c.YIELD:}},e.prototype._wsOnError=function(a){this._options.onError&&this._options.onError(a)},e.prototype._wsReconnect=function(){this._options.onReconnect&&this._options.onReconnect(),this._cache.reconnectingAttempts++,this._ws=b(this._url,this._protocols),this._initWsCallbacks()},e.prototype._renewSubscriptions=function(){var a,b,c=this._subscriptions,d=this._subsTopics;for(this._subscriptions={},this._subsTopics=[],a=d.length;a--;)for(b=c[d[a]].callbacks.length;b--;)this.subscribe(d[a],c[d[a]].callbacks[b])},e.prototype._renewRegistrations=function(){var a,b=this._rpcRegs,c=this._rpcNames;for(this._rpcRegs={},this._rpcNames=[],a=c.length;a--;)this.register(c[a],{rpc:b[c[a]].callbacks[0]})},e.prototype.options=function(a){return void 0===a?this._options:this._isPlainObject(a)?(this._options=this._merge(this._options,a),this):void 0},e.prototype.getOpStatus=function(){return this._cache.opStatus},e.prototype.getSessionId=function(){return this._cache.sessionId},e.prototype.connect=function(a){return a&&(this._url=a),this._setWsProtocols(),this._ws=b(this._url,this._protocols),this._initWsCallbacks(),this -},e.prototype.disconnect=function(){return this._cache.sessionId?(this._cache.isSayingGoodbye=!0,this._send([c.GOODBYE,{},"wamp.error.system_shutdown"])):this._ws&&this._ws.close(),this._cache.opStatus=d.SUCCESS,this},e.prototype.abort=function(){return this._cache.sessionId||1!==this._ws.readyState||(this._send([c.ABORT,{},"wamp.error.abort"]),this._cache.sessionId=null),this._ws.close(),this._cache.opStatus=d.SUCCESS,this},e.prototype.subscribe=function(a,b){var e;if(this._cache.sessionId&&!this._cache.server_wamp_features.roles.broker)return this._cache.opStatus=d.NO_BROKER,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;if(!this._validateURI(a))return this._cache.opStatus=d.URI_ERROR,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;if("function"==typeof b)b={onEvent:b};else if(!this._isPlainObject(b)||void 0===b.onEvent)return this._cache.opStatus=d.NO_CALLBACK_SPEC,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;return this._subscriptions[a]?(this._subscriptions[a].callbacks.indexOf(b.onEvent)<0&&this._subscriptions[a].callbacks.push(b.onEvent),b.onSuccess&&b.onSuccess()):(e=this._getReqId(),this._requests[e]={topic:a,callbacks:b},this._send([c.SUBSCRIBE,e,{},a])),this._cache.opStatus=d.SUCCESS,this},e.prototype.unsubscribe=function(a,b){var e,f=-1;return this._cache.sessionId&&!this._cache.server_wamp_features.roles.broker?(this._cache.opStatus=d.NO_BROKER,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this):this._subscriptions[a]?(e=this._getReqId(),void 0===b?(this._subscriptions[a].callbacks=[],b={}):"function"==typeof b?(f=this._subscriptions[a].callbacks.indexOf(b),b={onEvent:b}):f=this._subscriptions[a].callbacks.indexOf(b.onEvent),f>=0&&this._subscriptions[a].callbacks.splice(f,1),this._subscriptions[a].callbacks.length?(this._cache.opStatus=d.SUCCESS,this):(this._requests[e]={topic:a,callbacks:b},this._send([c.UNSUBSCRIBE,e,this._subscriptions[a].id]),this._cache.opStatus=d.SUCCESS,this)):(this._cache.opStatus=d.NON_EXIST_UNSUBSCRIBE,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this)},e.prototype.publish=function(a,b,e,f){var g,h,i={},j=!1;if(this._cache.sessionId&&!this._cache.server_wamp_features.roles.broker)return this._cache.opStatus=d.NO_BROKER,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;if(!this._validateURI(a))return this._cache.opStatus=d.URI_ERROR,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;if(this._isPlainObject(e)&&(i.acknowledge=!0),void 0!==f&&(this._isPlainObject(f)?(f.exclude&&(this._isArray(f.exclude)?i.exclude=f.exclude:"number"==typeof f.exclude?i.exclude=[f.exclude]:j=!0),f.eligible&&(this._isArray(f.eligible)?i.eligible=f.eligible:"number"==typeof f.eligible?i.eligible=[f.eligible]:j=!0),f.hasOwnProperty("exclude_me")&&(i.exclude_me=f.exclude_me!==!1),f.hasOwnProperty("disclose_me")&&(i.disclose_me=f.disclose_me===!0)):j=!0,j))return this._cache.opStatus=d.INVALID_PARAM,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;switch(g=this._getReqId(),arguments.length){case 1:h=[c.PUBLISH,g,i,a];break;case 2:h=this._isArray(b)?[c.PUBLISH,g,i,a,b]:this._isPlainObject(b)?[c.PUBLISH,g,i,a,[],b]:[c.PUBLISH,g,i,a,[b]];break;default:this._requests[g]={topic:a,callbacks:e},h=this._isArray(b)?[c.PUBLISH,g,i,a,b]:this._isPlainObject(b)?[c.PUBLISH,g,i,a,[],b]:[c.PUBLISH,g,i,a,[b]]}return this._send(h),this._cache.opStatus=d.SUCCESS,this},e.prototype.call=function(a,b,e,f){var g,h,i={},j=!1;if(this._cache.sessionId&&!this._cache.server_wamp_features.roles.dealer)return this._cache.opStatus=d.NO_DEALER,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;if(!this._validateURI(a))return this._cache.opStatus=d.URI_ERROR,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;if("function"==typeof e)e={onSuccess:e};else if(!this._isPlainObject(e)||void 0===e.onSuccess)return this._cache.opStatus=d.NO_CALLBACK_SPEC,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;if(void 0!==f&&(this._isPlainObject(f)?(f.exclude&&(this._isArray(f.exclude)?i.exclude=f.exclude:"number"==typeof f.exclude?i.exclude=[f.exclude]:j=!0),f.eligible&&(this._isArray(f.eligible)?i.eligible=f.eligible:"number"==typeof f.eligible?i.eligible=[f.eligible]:j=!0),f.hasOwnProperty("exclude_me")&&(i.exclude_me=f.exclude_me!==!1),f.hasOwnProperty("disclose_me")&&(i.disclose_me=f.disclose_me===!0)):j=!0,j))return this._cache.opStatus=d.INVALID_PARAM,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;do g=this._getReqId();while(g in this._calls);return this._calls[g]=e,h=null===b?[c.CALL,g,i,a]:this._isArray(b)?[c.CALL,g,i,a,b]:this._isPlainObject(b)?[c.CALL,g,i,a,[],b]:[c.CALL,g,i,a,[b]],this._send(h),this._cache.opStatus=d.SUCCESS,this},e.prototype.register=function(a,b){var e;if(this._cache.sessionId&&!this._cache.server_wamp_features.roles.dealer)return this._cache.opStatus=d.NO_DEALER,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;if(!this._validateURI(a))return this._cache.opStatus=d.URI_ERROR,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;if("function"==typeof b)b={rpc:b};else if(!this._isPlainObject(b)||void 0===b.rpc)return this._cache.opStatus=d.NO_CALLBACK_SPEC,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;return this._rpcRegs[a]?(this._cache.opStatus=d.RPC_ALREADY_REGISTERED,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description)):(e=this._getReqId(),this._requests[e]={topic:a,callbacks:b},this._send([c.REGISTER,e,{},a]),this._cache.opStatus=d.SUCCESS),this},e.prototype.unregister=function(a,b){var e;return this._cache.sessionId&&!this._cache.server_wamp_features.roles.dealer?(this._cache.opStatus=d.NO_DEALER,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this):this._validateURI(a)?("function"==typeof b&&(b={onSuccess:b}),this._rpcRegs[a]?(e=this._getReqId(),this._requests[e]={topic:a,callbacks:b},this._send([c.UNREGISTER,e,this._rpcRegs[a].id]),this._cache.opStatus=d.SUCCESS):(this._cache.opStatus=d.RPC_ALREADY_REGISTERED,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description)),this):(this._cache.opStatus=d.URI_ERROR,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this)},e}); \ No newline at end of file +!function(a){var b=this;"object"==typeof exports?module.exports=a(b):"function"==typeof define&&define.amd?define([],function(){return a(b)}):b.jDataView=a(b)}(function(a){"use strict";function b(a,b){return!b&&a instanceof Array?a:Array.prototype.slice.call(a)}function c(a,b){return void 0!==a?a:b}function d(a,b,e,f){if(a instanceof d){var g=a.slice(b,b+e);return g._littleEndian=c(f,g._littleEndian),g}if(!(this instanceof d))return new d(a,b,e,f);if(this.buffer=a=d.wrapBuffer(a),this._isArrayBuffer=i.ArrayBuffer&&a instanceof ArrayBuffer,this._isPixelData=!0&&i.PixelData&&a instanceof CanvasPixelArray,this._isDataView=i.DataView&&this._isArrayBuffer,this._isNodeBuffer=!1,!(this._isArrayBuffer||this._isPixelData||a instanceof Array))throw new TypeError("jDataView buffer has an incompatible type");this._littleEndian=!!f;var h="byteLength"in a?a.byteLength:a.length;this.byteOffset=b=c(b,0),this.byteLength=e=c(e,h-b),this._offset=this._bitOffset=0,this._isDataView?this._view=new DataView(a,b,e):this._checkBounds(b,e,h),this._engineAction=this._isDataView?this._dataViewAction:this._isArrayBuffer?this._arrayBufferAction:this._arrayAction}function e(a){for(var b=i.ArrayBuffer?Uint8Array:Array,c=new b(a.length),d=0,e=a.length;e>d;d++)c[d]=255&a.charCodeAt(d);return c}function f(a){return a>=0&&31>a?1<d;d++)c[d]=b[d];return c};l.context2d=document.createElement("canvas").getContext("2d")}var m={Int8:1,Int16:2,Int32:4,Uint8:1,Uint16:2,Uint32:4,Float32:4,Float64:8};d.wrapBuffer=function(a){switch(typeof a){case"number":if(i.ArrayBuffer)a=new Uint8Array(a).buffer;else if(i.PixelData)a=l(a);else{a=new Array(a);for(var c=0;c=0){var d=g.fromNumber(a);b=d.lo,c=d.hi}else c=Math.floor(a/f(32)),b=a-c*f(32),c+=f(32);return new h(b,c)};var n=d.prototype={compatibility:i,_checkBounds:function(a,b,d){if("number"!=typeof a)throw new TypeError("Offset is not a number.");if("number"!=typeof b)throw new TypeError("Size is not a number.");if(0>b)throw new RangeError("Length is negative.");if(0>a||a+b>c(d,this.byteLength))throw new RangeError("Offsets are out of bounds.")},_action:function(a,b,d,e,f){return this._engineAction(a,b,c(d,this._offset),c(e,this._littleEndian),f)},_dataViewAction:function(a,b,c,d,e){return this._offset=c+m[a],b?this._view["get"+a](c,d):this._view["set"+a](c,e,d)},_arrayBufferAction:function(b,d,e,f,g){var h,i=m[b],j=a[b+"Array"];if(f=c(f,this._littleEndian),1===i||(this.byteOffset+e)%i===0&&f)return h=new j(this.buffer,this.byteOffset+e,1),this._offset=e+i,d?h[0]:h[0]=g;var k=new Uint8Array(d?this.getBytes(i,e,f,!0):i);return h=new j(k.buffer,0,1),d?h[0]:(h[0]=g,void this._setBytes(e,k,f))},_arrayAction:function(a,b,c,d,e){return b?this["_get"+a](c,d):this["_set"+a](c,e,d)},_getBytes:function(a,d,e){e=c(e,this._littleEndian),d=c(d,this._offset),a=c(a,this.byteLength-d),this._checkBounds(d,a),d+=this.byteOffset,this._offset=d-this.byteOffset+a;var f=this._isArrayBuffer?new Uint8Array(this.buffer,d,a):(this.buffer.slice||Array.prototype.slice).call(this.buffer,d,d+a);return e||1>=a?f:b(f).reverse()},getBytes:function(a,d,e,f){var g=this._getBytes(a,d,c(e,!0));return f?b(g):g},_setBytes:function(a,d,e){var f=d.length;if(0!==f){if(e=c(e,this._littleEndian),a=c(a,this._offset),this._checkBounds(a,f),!e&&f>1&&(d=b(d,!0).reverse()),a+=this.byteOffset,this._isArrayBuffer)new Uint8Array(this.buffer,a,f).set(d);else for(var g=0;f>g;g++)this.buffer[a+g]=d[g];this._offset=a-this.byteOffset+f}},setBytes:function(a,b,d){this._setBytes(a,b,c(d,!0))},getString:function(a,b,c){var d=this._getBytes(a,b,!0);if(c="utf8"===c?"utf-8":c||"binary",k&&"binary"!==c)return new k(c).decode(this._isArrayBuffer?d:new Uint8Array(d));var e="";a=d.length;for(var f=0;a>f;f++)e+=String.fromCharCode(d[f]);return"utf-8"===c&&(e=decodeURIComponent(escape(e))),e},setString:function(a,b,c){c="utf8"===c?"utf-8":c||"binary";var d;j&&"binary"!==c?d=new j(c).encode(b):("utf-8"===c&&(b=unescape(encodeURIComponent(b))),d=e(b)),this._setBytes(a,d,!0)},getChar:function(a){return this.getString(1,a)},setChar:function(a,b){this.setString(a,b)},tell:function(){return this._offset},seek:function(a){return this._checkBounds(a,0),this._offset=a},skip:function(a){return this.seek(this._offset+a)},slice:function(a,b,e){function f(a,b){return 0>a?a+b:a}return a=f(a,this.byteLength),b=f(c(b,this.byteLength),this.byteLength),e?new d(this.getBytes(b-a,a,!0,!0),void 0,void 0,this._littleEndian):new d(this.buffer,this.byteOffset+a,b-a,this._littleEndian)},alignBy:function(a){return this._bitOffset=0,1!==c(a,1)?this.skip(a-(this._offset%a||a)):this._offset},_getFloat64:function(a,b){var c=this._getBytes(8,a,b),d=1-2*(c[7]>>7),e=((c[7]<<1&255)<<3|c[6]>>4)-1023,g=(15&c[6])*f(48)+c[5]*f(40)+c[4]*f(32)+c[3]*f(24)+c[2]*f(16)+c[1]*f(8)+c[0];return 1024===e?0!==g?0/0:1/0*d:-1023===e?d*g*f(-1074):d*(1+g*f(-52))*f(e)},_getFloat32:function(a,b){var c=this._getBytes(4,a,b),d=1-2*(c[3]>>7),e=(c[3]<<1&255|c[2]>>7)-127,g=(127&c[2])<<16|c[1]<<8|c[0];return 128===e?0!==g?0/0:1/0*d:-127===e?d*g*f(-149):d*(1+g*f(-23))*f(e)},_get64:function(a,b,d){d=c(d,this._littleEndian),b=c(b,this._offset);for(var e=d?[0,4]:[4,0],f=0;2>f;f++)e[f]=this.getUint32(b+e[f],d);return this._offset=b+8,new a(e[0],e[1])},getInt64:function(a,b){return this._get64(h,a,b)},getUint64:function(a,b){return this._get64(g,a,b)},_getInt32:function(a,b){var c=this._getBytes(4,a,b);return c[3]<<24|c[2]<<16|c[1]<<8|c[0]},_getUint32:function(a,b){return this._getInt32(a,b)>>>0},_getInt16:function(a,b){return this._getUint16(a,b)<<16>>16},_getUint16:function(a,b){var c=this._getBytes(2,a,b);return c[1]<<8|c[0]},_getInt8:function(a){return this._getUint8(a)<<24>>24},_getUint8:function(a){return this._getBytes(1,a)[0]},_getBitRangeData:function(a,b){var d=(c(b,this._offset)<<3)+this._bitOffset,e=d+a,f=d>>>3,g=e+7>>>3,h=this._getBytes(g-f,f,!0),i=0;(this._bitOffset=7&e)&&(this._bitOffset-=8);for(var j=0,k=h.length;k>j;j++)i=i<<8|h[j];return{start:f,bytes:h,wideValue:i}},getSigned:function(a,b){var c=32-a;return this.getUnsigned(a,b)<>c},getUnsigned:function(a,b){var c=this._getBitRangeData(a,b).wideValue>>>-this._bitOffset;return 32>a?c&~(-1<b?1:0,j=~(-1<b&&(b=-b),0===b?(g=0,h=0):isNaN(b)?(g=2*j+1,h=1):1/0===b?(g=2*j+1,h=0):(g=Math.floor(Math.log(b)/Math.LN2),g>=k&&j>=g?(h=Math.floor((b*f(-g)-1)*f(c)),g+=j):(h=Math.floor(b/f(k-c)),g=0));for(var l=[];c>=8;)l.push(h%256),h=Math.floor(h/256),c-=8;for(g=g<=8;)l.push(255&g),g>>>=8,d-=8;l.push(i<>>8&255,b>>>16&255,b>>>24],c)},_setUint16:function(a,b,c){this._setBytes(a,[255&b,b>>>8&255],c)},_setUint8:function(a,b){this._setBytes(a,[255&b])},setUnsigned:function(a,b,c){var d=this._getBitRangeData(c,a),e=d.wideValue,f=d.bytes;e&=~(~(-1<c?b&~(-1<=0;g--)f[g]=255&e,e>>>=8;this._setBytes(d.start,f,!0)}};for(var o in m)!function(a){n["get"+a]=function(b,c){return this._action(a,!0,b,c)},n["set"+a]=function(b,c,d){this._action(a,!1,b,d,c)}}(o);n._setInt32=n._setUint32,n._setInt16=n._setUint16,n._setInt8=n._setUint8,n.setSigned=n.setUnsigned;for(var p in n)"set"===p.slice(0,3)&&!function(a){n["write"+a]=function(){Array.prototype.unshift.call(arguments,void 0),this["set"+a].apply(this,arguments)}}(p.slice(3));return d}); +//# sourceMappingURL=jdataview.js.map +("function"==typeof define?function(a){define("msgpack-js",a)}:"object"==typeof exports?function(a){module.exports=a()}:function(a){this.msgpack=a()})(function(){"use strict";function a(a){if(void 0===a)return"undefined";var b,c;if(a instanceof ArrayBuffer?(c="ArrayBuffer",b=new DataView(a)):a instanceof DataView&&(c="DataView",b=a),!b)return JSON.stringify(a);for(var d=[],e=0;e20){d.push("...");break}var f=b.getUint8(e).toString(16);1===f.length&&(f="0"+f),d.push(f)}return"<"+c+" "+d.join(" ")+">"}function b(a,b,c){for(var d=(a.byteLength,0),e=c.length;e>d;d++){var f=c.charCodeAt(d);if(128>f)a.setUint8(b++,f>>>0&127|0);else if(2048>f)a.setUint8(b++,f>>>6&31|192),a.setUint8(b++,f>>>0&63|128);else if(65536>f)a.setUint8(b++,f>>>12&15|224),a.setUint8(b++,f>>>6&63|128),a.setUint8(b++,f>>>0&63|128);else{if(!(1114112>f))throw new Error("bad codepoint "+f);a.setUint8(b++,f>>>18&7|240),a.setUint8(b++,f>>>12&63|128),a.setUint8(b++,f>>>6&63|128),a.setUint8(b++,f>>>0&63|128)}}}function c(a,b,c){for(var d="",e=b,f=b+c;f>e;e++){var g=a.getUint8(e);if(0!==(128&g))if(192!==(224&g))if(224!==(240&g)){if(240!==(248&g))throw new Error("Invalid byte "+g.toString(16));d+=String.fromCharCode((7&g)<<18|(63&a.getUint8(++e))<<12|(63&a.getUint8(++e))<<6|(63&a.getUint8(++e))<<0)}else d+=String.fromCharCode((15&g)<<12|(63&a.getUint8(++e))<<6|(63&a.getUint8(++e))<<0);else d+=String.fromCharCode((15&g)<<6|63&a.getUint8(++e));else d+=String.fromCharCode(g)}return d}function d(a){for(var b=0,c=0,d=a.length;d>c;c++){var e=a.charCodeAt(c);if(128>e)b+=1;else if(2048>e)b+=2;else if(65536>e)b+=3;else{if(!(1114112>e))throw new Error("bad codepoint "+e);b+=4}}return b}function e(a,b){this.offset=b||0,this.view=a}function f(a){var b=new jDataView(a),c=new e(b),d=c.parse();if(c.offset!==a.byteLength)throw new Error(a.byteLength-c.offset+" trailing bytes");return d}function g(a,c,e){var f,h,i,j,k=typeof a;if("string"===k){if(f=d(a),32>f)return c.setUint8(e,160|f),b(c,e+1,a),1+f;if(256>f)return c.setUint8(e,217),c.setUint16(e+1,f),b(c,e+2,a),2+f;if(65536>f)return c.setUint8(e,218),c.setUint16(e+1,f),b(c,e+3,a),3+f;if(4294967296>f)return c.setUint8(e,219),c.setUint32(e+1,f),b(c,e+5,a),5+f}if(a instanceof ArrayBuffer){if(f=a.byteLength,256>f)return c.setUint8(e,196),c.setUint16(e+1,f),new Uint8Array(c.buffer).set(new Uint8Array(a),e+2),2+f;if(65536>f)return c.setUint8(e,216),c.setUint16(e+1,f),new Uint8Array(c.buffer).set(new Uint8Array(a),e+3),3+f;if(4294967296>f)return c.setUint8(e,217),c.setUint32(e+1,f),new Uint8Array(c.buffer).set(new Uint8Array(a),e+5),5+f}if("number"===k){if(a%1!==0)return c.setUint8(e,203),c.setFloat64(e+1,a),9;if(a>=0){if(128>a)return c.setUint8(e,a),1;if(256>a)return c.setUint8(e,204),c.setUint8(e+1,a),2;if(65536>a)return c.setUint8(e,205),c.setUint16(e+1,a),3;if(4294967296>a)return c.setUint8(e,206),c.setUint32(e+1,a),5;if(0x10000000000000000>a)return c.setUint8(e,207),c.setUint64(e+1,a),9;throw new Error("Number too big 0x"+a.toString(16))}if(a>=-32)return c.setInt8(e,a),1;if(a>=-128)return c.setUint8(e,208),c.setInt8(e+1,a),2;if(a>=-32768)return c.setUint8(e,209),c.setInt16(e+1,a),3;if(a>=-2147483648)return c.setUint8(e,210),c.setInt32(e+1,a),5;if(a>=-2147483648)return c.setUint8(e,211),c.setUint64(e+1,a),9;throw new Error("Number too small -0x"+(-a).toString(16).substr(1))}if("undefined"===k)return c.setUint8(e,212),c.setUint8(e+1,0),c.setUint8(e+2,0),1;if(null===a)return c.setUint8(e,192),1;if("boolean"===k)return c.setUint8(e,a?195:194),1;if("function"==typeof a.toJSON)return g(a.toJSON(),c,e);if("object"===k){if(h=0,i=Array.isArray(a))f=a.length;else{var l=Object.keys(a);f=l.length}if(16>f?(c.setUint8(e,f|(i?144:128)),h=1):65536>f?(c.setUint8(e,i?220:222),c.setUint16(e+1,f),h=3):4294967296>f&&(c.setUint8(e,i?221:223),c.setUint32(e+1,f),h=5),i)for(j=0;f>j;j++)h+=g(a[j],c,e+h);else for(j=0;f>j;j++){var m=l[j];h+=g(m,c,e+h),h+=g(a[m],c,e+h)}return h}throw new Error("Unknown type "+k)}function h(a){var b,c,e,f,g=typeof a;if("string"===g){if(b=d(a),32>b)return 1+b;if(256>b)return 2+b;if(65536>b)return 3+b;if(4294967296>b)return 5+b}if(a instanceof ArrayBuffer){if(b=a.byteLength,256>b)return 2+b;if(65536>b)return 3+b;if(4294967296>b)return 5+b}if("number"===g){if(a<<0!==a)return 9;if(a>=0){if(128>a)return 1;if(256>a)return 2;if(65536>a)return 3;if(4294967296>a)return 5;if(0x10000000000000000>a)return 9;throw new Error("Number too big 0x"+a.toString(16))}if(a>=-32)return 1;if(a>=-128)return 2;if(a>=-32768)return 3;if(a>=-2147483648)return 5;if(a>=-0x8000000000000000)return 9;throw new Error("Number too small -0x"+a.toString(16).substr(1))}if("boolean"===g||null===a)return 1;if("undefined"===g)return 3;if("function"==typeof a.toJSON)return h(a.toJSON());if("object"===g){if("function"==typeof a.toJSON&&(a=a.toJSON()),c=0,Array.isArray(a))for(b=a.length,f=0;b>f;f++)c+=h(a[f]);else for(e=Object.keys(a),b=e.length,f=0;b>f;f++)c+=h(e[f])+h(a[e[f]]);if(16>b)return 1+c;if(65536>b)return 3+c;if(4294967296>b)return 5+c;throw new Error("Array or object too long 0x"+b.toString(16))}if("function"===g)return 0;throw new Error("Unknown type "+g)}var i={};return i.inspect=a,i.utf8Write=b,i.utf8Read=c,i.utf8ByteCount=d,i.encode=function(a){var b=new ArrayBuffer(h(a)),c=new jDataView(b);return g(a,c,0),b},i.decode=f,e.prototype.map=function(a){for(var b={},c=0;a>c;c++){var d=this.parse();b[d]=this.parse()}return b},e.prototype.buf=function(a){var b=new ArrayBuffer(a);return new Uint8Array(b).set(new Uint8Array(this.view.buffer,this.offset,a),0),this.offset+=a,b},e.prototype.u8str=function(a){var b=c(this.view,this.offset,a);return this.offset+=a,b},e.prototype.array=function(a){for(var b=new Array(a),c=0;a>c;c++)b[c]=this.parse();return b},e.prototype.parse=function(){var a,b,c,d=this.view.getUint8(this.offset);if(0===(128&d))return this.offset++,d;if(128===(240&d))return b=15&d,this.offset++,this.map(b);if(144===(240&d))return b=15&d,this.offset++,this.array(b);if(160===(224&d))return b=31&d,this.offset++,this.u8str(b);if(224===(224&d))return a=this.view.getInt8(this.offset),this.offset++,a;switch(d){case 192:return this.offset++,null;case 194:return this.offset++,!1;case 195:return this.offset++,!0;case 196:return b=this.view.getUint8(this.offset+1),this.offset+=2,this.buf(b);case 197:return b=this.view.getUint16(this.offset+1),this.offset+=3,this.buf(b);case 198:return b=this.view.getUint32(this.offset+1),this.offset+=5,this.buf(b);case 199:return b=this.view.getUint8(this.offset+1),c=this.view.getUint8(this.offset+2),this.offset+=3,[c,this.buf(b)];case 200:return b=this.view.getUint16(this.offset+1),c=this.view.getUint8(this.offset+3),this.offset+=4,[c,this.buf(b)];case 201:return b=this.view.getUint32(this.offset+1),c=this.view.getUint8(this.offset+5),this.offset+=6,[c,this.buf(b)];case 202:return a=this.view.getFloat32(this.offset+1),this.offset+=5,a;case 203:return a=this.view.getFloat64(this.offset+1),this.offset+=9,a;case 204:return a=this.view.getUint8(this.offset+1),this.offset+=2,a;case 205:return a=this.view.getUint16(this.offset+1),this.offset+=3,a;case 206:return a=this.view.getUint32(this.offset+1),this.offset+=5,a;case 207:return a=this.view.getUint64(this.offset+1),this.offset+=9,parseInt(a);case 208:return a=this.view.getInt8(this.offset+1),this.offset+=2,a;case 209:return a=this.view.getInt16(this.offset+1),this.offset+=3,a;case 210:return a=this.view.getInt32(this.offset+1),this.offset+=5,a;case 211:return a=this.view.getInt64(this.offset+1),this.offset+=9,parseInt(a);case 212:return c=this.view.getUint8(this.offset+1),a=this.view.getUint8(this.offset+2),this.offset+=3,0===c&&0===a?void 0:[c,a];case 213:return c=this.view.getUint8(this.offset+1),this.offset+=2,[c,this.buf(2)];case 214:return c=this.view.getUint8(this.offset+1),this.offset+=2,[c,this.buf(4)];case 215:return c=this.view.getUint8(this.offset+1),this.offset+=2,[c,this.buf(8)];case 216:return c=this.view.getUint8(this.offset+1),this.offset+=2,[c,this.buf(16)];case 217:return b=this.view.getUint8(this.offset+1),this.offset+=2,this.u8str(b);case 218:return b=this.view.getUint16(this.offset+1),this.offset+=3,this.u8str(b);case 219:return b=this.view.getUint32(this.offset+1),this.offset+=5,this.u8str(b);case 220:return b=this.view.getUint16(this.offset+1),this.offset+=3,this.array(b);case 221:return b=this.view.getUint32(this.offset+1),this.offset+=5,this.array(b);case 222:return b=this.view.getUint16(this.offset+1),this.offset+=3,this.map(b);case 223:return b=this.view.getUint32(this.offset+1),this.offset+=5,this.map(b)}throw new Error("Unknown type 0x"+d.toString(16))},i}); +/** + * Project: wampy.js + * + * https://github.com/KSDaemon/wampy.js + * + * A lightweight client-side implementation of + * WAMP (The WebSocket Application Messaging Protocol v2) + * http://wamp.ws + * + * Provides asynchronous RPC/PubSub over WebSocket. + * + * Copyright 2014 KSDaemon. Licensed under the MIT License. + * See @license text at http://www.opensource.org/licenses/mit-license.php + * + */ +("function"==typeof define?function(a){define("Wampy",a)}:"object"==typeof exports?function(a){module.exports=a()}:function(a){this.Wampy=a()})(function(){function a(a){var b,c,d;return a?/^ws/.test(a)?a:/:\d{1,5}/.test(a)?(b="https:"===window.location.protocol?"wss://":"ws://",b+a):(b="https:"===window.location.protocol?"wss://":"ws://",c=""!==window.location.port?":"+window.location.port:"",d="/"===a[0]?a:"/"+a,b+window.location.hostname+c+d):(b="https:"===window.location.protocol?"wss://":"ws://",c=""!==window.location.port?":"+window.location.port:"",b+window.location.hostname+c+"/ws")}function b(b,c){var d=a(b);return"WebSocket"in window?c?new WebSocket(d,c):new WebSocket(d):"MozWebSocket"in window?c?new MozWebSocket(d,c):new MozWebSocket(d):null}var c={HELLO:1,WELCOME:2,ABORT:3,CHALLENGE:4,AUTHENTICATE:5,GOODBYE:6,HEARTBEAT:7,ERROR:8,PUBLISH:16,PUBLISHED:17,SUBSCRIBE:32,SUBSCRIBED:33,UNSUBSCRIBE:34,UNSUBSCRIBED:35,EVENT:36,CALL:48,CANCEL:49,RESULT:50,REGISTER:64,REGISTERED:65,UNREGISTER:66,UNREGISTERED:67,INVOCATION:68,INTERRUPT:69,YIELD:70},d={SUCCESS:{code:0,description:"Success!"},URI_ERROR:{code:1,description:"Topic URI doesn't meet requirements!"},NO_BROKER:{code:2,description:"Server doesn't provide broker role!"},NO_CALLBACK_SPEC:{code:3,description:"No required callback function specified!"},INVALID_PARAM:{code:4,description:"Invalid parameter(s) specified!"},NON_EXIST_SUBSCRIBE_CONFIRM:{code:5,description:"Received subscribe confirmation to non existent subscription!"},NON_EXIST_SUBSCRIBE_ERROR:{code:6,description:"Received error for non existent subscription!"},NON_EXIST_UNSUBSCRIBE:{code:7,description:"Trying to unsubscribe from non existent subscription!"},NON_EXIST_SUBSCRIBE_UNSUBSCRIBED:{code:8,description:"Received unsubscribe confirmation to non existent subscription!"},NON_EXIST_PUBLISH_ERROR:{code:9,description:"Received error for non existent publication!"},NON_EXIST_PUBLISH_PUBLISHED:{code:10,description:"Received publish confirmation for non existent publication!"},NON_EXIST_SUBSCRIBE_EVENT:{code:11,description:"Received event for non existent subscription!"},NO_DEALER:{code:12,description:"Server doesn't provide dealer role!"},NON_EXIST_CALL_RESULT:{code:13,description:"Received rpc result for non existent call!"},NON_EXIST_CALL_ERROR:{code:14,description:"Received rpc call error for non existent call!"},RPC_ALREADY_REGISTERED:{code:15,description:"RPC already registered!"},NON_EXIST_RPC_REG:{code:16,description:"Received rpc registration confirmation for non existent rpc!"},NON_EXIST_RPC_UNREG:{code:17,description:"Received rpc unregistration confirmation for non existent rpc!"},NON_EXIST_RPC_ERROR:{code:18,description:"Received error for non existent rpc!"},NON_EXIST_RPC_INVOCATION:{code:19,description:"Received invocation for non existent rpc!"}},e=function(a,c){switch(this.version="v1.0.4",this._url="string"==typeof arguments[0]?a:void 0,this._protocols=["wamp.2.json"],this._wamp_features={agent:"Wampy.js "+this.version,roles:{publisher:{features:{subscriber_blackwhite_listing:!0,publisher_exclusion:!0,publisher_identification:!0}},subscriber:{},caller:{features:{callee_blackwhite_listing:!0,caller_exclusion:!0,caller_identification:!0}},callee:{features:{caller_identification:!0}}}},this._cache={sessionId:null,server_wamp_features:{roles:{}},isSayingGoodbye:!1,opStatus:{code:0,description:"Success!"},timer:null,reconnectingAttempts:0},this._ws=null,this._wsQueue=[],this._requests={},this._calls={},this._subscriptions={},this._subsTopics=[],this._rpcRegs={},this._rpcNames=[],this._options={autoReconnect:!0,reconnectInterval:2e3,maxRetries:25,transportEncoding:"json",realm:window.location.hostname,onConnect:null,onClose:null,onError:null,onReconnect:null},arguments.length){case 1:"string"!=typeof arguments[0]&&(this._options=this._merge(this._options,arguments[0]));break;case 2:this._options=this._merge(this._options,c)}this._setWsProtocols(),this._ws=b(this._url,this._protocols),this._initWsCallbacks()};return e.prototype._getReqId=function(){var a;do a=Math.floor(1e14*Math.random());while(a in this._requests);return a},e.prototype._merge=function(){var a,b,c={},d=arguments.length;for(a=0;d>a;a++)for(b in arguments[a])c[b]=arguments[a][b];return c},e.prototype._isArray=function(a){return!!a&&a.constructor===Array},e.prototype._isObject=function(a){return a===Object(a)&&"[object Array]"!==Object.prototype.toString.call(a)},e.prototype._isPlainObject=function(a){return!!a&&a.constructor===Object},e.prototype._setWsProtocols=function(){void 0!==window.msgpack&&(this._protocols="msgpack"===this._options.transportEncoding?["wamp.2.msgpack","wamp.2.json"]:["wamp.2.json","wamp.2.msgpack"])},e.prototype._validateURI=function(a){var b=/^([0-9a-z_]{2,}\.)*([0-9a-z_]{2,})$/;return b.test(a)&&0!==a.indexOf("wamp")?!0:!1},e.prototype._encode=function(a){var b;if("msgpack"!==this._options.transportEncoding)return JSON.stringify(a);try{return b=new Uint8Array(msgpack.encode(a)),b.buffer}catch(c){throw new Error("[wampy] no msgpack encoder available!")}},e.prototype._decode=function(a){if("msgpack"!==this._options.transportEncoding)return JSON.parse(a);try{return msgpack.decode(a)}catch(b){throw new Error("[wampy] no msgpack encoder available!")}},e.prototype._send=function(a){if(a&&this._wsQueue.push(this._encode(a)),1===this._ws.readyState&&this._cache.sessionId)for(;this._wsQueue.length;)this._ws.send(this._wsQueue.shift())},e.prototype._resetState=function(){this._wsQueue=[],this._subscriptions={},this._subsTopics=[],this._requests={},this._calls={},this._rpcRegs={},this._rpcNames=[],this._cache={reconnectingAttempts:0}},e.prototype._initWsCallbacks=function(){var a=this;this._ws.onopen=function(){a._wsOnOpen.call(a)},this._ws.onclose=function(b){a._wsOnClose.call(a,b)},this._ws.onmessage=function(b){a._wsOnMessage.call(a,b)},this._ws.onerror=function(b){a._wsOnError.call(a,b)}},e.prototype._wsOnOpen=function(){var a;a=this._ws.protocol.split("."),this._options.transportEncoding=a[2],"msgpack"===this._options.transportEncoding&&(this._ws.binaryType="arraybuffer"),this._ws.send(this._encode([c.HELLO,this._options.realm,this._wamp_features]))},e.prototype._wsOnClose=function(){var a=this;(this._cache.sessionId||this._cache.reconnectingAttempts)&&this._options.autoReconnect&&this._cache.reconnectingAttempts=0&&this._subsTopics.splice(f,1),this._requests[b[1]].callbacks.onSuccess&&this._requests[b[1]].callbacks.onSuccess(),delete this._requests[b[1]]):this._cache.opStatus=d.NON_EXIST_SUBSCRIBE_UNSUBSCRIBED;break;case c.PUBLISHED:this._requests[b[1]]?(this._requests[b[1]].callbacks.onSuccess&&this._requests[b[1]].callbacks.onSuccess(),delete this._requests[b[1]]):this._cache.opStatus=d.NON_EXIST_PUBLISH_PUBLISHED;break;case c.EVENT:if(this._subscriptions[b[1]]){switch(b.length){case 4:g=null;break;case 5:g=b[4];break;case 6:g=b[5]}for(f=this._subscriptions[b[1]].callbacks.length;f--;)this._subscriptions[b[1]].callbacks[f](g)}else this._cache.opStatus=d.NON_EXIST_SUBSCRIBE_EVENT;break;case c.RESULT:if(this._calls[b[1]]){switch(b.length){case 3:g=null;break;case 4:g=b[3];break;case 5:g=b[4]}this._calls[b[1]].onSuccess(g),delete this._calls[b[1]]}else this._cache.opStatus=d.NON_EXIST_CALL_RESULT;break;case c.REGISTER:break;case c.REGISTERED:this._requests[b[1]]?(this._rpcRegs[this._requests[b[1]].topic]=this._rpcRegs[b[2]]={id:b[2],callbacks:[this._requests[b[1]].callbacks.rpc]},this._rpcNames.push(this._requests[b[1]].topic),this._requests[b[1]].callbacks.onSuccess&&this._requests[b[1]].callbacks.onSuccess(),delete this._requests[b[1]]):this._cache.opStatus=d.NON_EXIST_RPC_REG;break;case c.UNREGISTER:break;case c.UNREGISTERED:this._requests[b[1]]?(e=this._rpcRegs[this._requests[b[1]].topic].id,delete this._rpcRegs[this._requests[b[1]].topic],delete this._rpcRegs[e],f=this._rpcNames.indexOf(this._requests[b[1]].topic),f>=0&&this._rpcNames.splice(f,1),this._requests[b[1]].callbacks.onSuccess&&this._requests[b[1]].callbacks.onSuccess(),delete this._requests[b[1]]):this._cache.opStatus=d.NON_EXIST_RPC_UNREG;break;case c.INVOCATION:if(this._rpcRegs[b[2]]){switch(b.length){case 4:g=null;break;case 5:g=b[4];break;case 6:g=b[5]}try{h=this._rpcRegs[b[2]].callbacks[0](g)}catch(j){return void this._send([c.ERROR,c.INVOCATION,b[1],{},"wamp.error.invocation_exception"])}i=this._isArray(h)?[c.YIELD,b[1],{},h]:this._isPlainObject(h)?[c.YIELD,b[1],{},[],h]:void 0===h?[c.YIELD,b[1],{}]:[c.YIELD,b[1],{},[h]],this._send(i)}else this._send([c.ERROR,c.INVOCATION,b[1],{},"wamp.error.no_such_procedure"]),this._cache.opStatus=d.NON_EXIST_RPC_INVOCATION;break;case c.INTERRUPT:break;case c.YIELD:}},e.prototype._wsOnError=function(a){this._options.onError&&this._options.onError(a)},e.prototype._wsReconnect=function(){this._options.onReconnect&&this._options.onReconnect(),this._cache.reconnectingAttempts++,this._ws=b(this._url,this._protocols),this._initWsCallbacks()},e.prototype._renewSubscriptions=function(){var a,b,c=this._subscriptions,d=this._subsTopics;for(this._subscriptions={},this._subsTopics=[],a=d.length;a--;)for(b=c[d[a]].callbacks.length;b--;)this.subscribe(d[a],c[d[a]].callbacks[b])},e.prototype._renewRegistrations=function(){var a,b=this._rpcRegs,c=this._rpcNames;for(this._rpcRegs={},this._rpcNames=[],a=c.length;a--;)this.register(c[a],{rpc:b[c[a]].callbacks[0]})},e.prototype.options=function(a){return void 0===a?this._options:this._isPlainObject(a)?(this._options=this._merge(this._options,a),this):void 0},e.prototype.getOpStatus=function(){return this._cache.opStatus},e.prototype.getSessionId=function(){return this._cache.sessionId},e.prototype.connect=function(a){return a&&(this._url=a),this._setWsProtocols(),this._ws=b(this._url,this._protocols),this._initWsCallbacks(),this},e.prototype.disconnect=function(){return this._cache.sessionId?(this._cache.isSayingGoodbye=!0,this._send([c.GOODBYE,{},"wamp.error.system_shutdown"])):this._ws&&this._ws.close(),this._cache.opStatus=d.SUCCESS,this},e.prototype.abort=function(){return this._cache.sessionId||1!==this._ws.readyState||(this._send([c.ABORT,{},"wamp.error.abort"]),this._cache.sessionId=null),this._ws.close(),this._cache.opStatus=d.SUCCESS,this},e.prototype.subscribe=function(a,b){var e;if(this._cache.sessionId&&!this._cache.server_wamp_features.roles.broker)return this._cache.opStatus=d.NO_BROKER,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;if(!this._validateURI(a))return this._cache.opStatus=d.URI_ERROR,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;if("function"==typeof b)b={onEvent:b};else if(!this._isPlainObject(b)||void 0===b.onEvent)return this._cache.opStatus=d.NO_CALLBACK_SPEC,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;return this._subscriptions[a]?(this._subscriptions[a].callbacks.indexOf(b.onEvent)<0&&this._subscriptions[a].callbacks.push(b.onEvent),b.onSuccess&&b.onSuccess()):(e=this._getReqId(),this._requests[e]={topic:a,callbacks:b},this._send([c.SUBSCRIBE,e,{},a])),this._cache.opStatus=d.SUCCESS,this},e.prototype.unsubscribe=function(a,b){var e,f=-1;return this._cache.sessionId&&!this._cache.server_wamp_features.roles.broker?(this._cache.opStatus=d.NO_BROKER,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this):this._subscriptions[a]?(e=this._getReqId(),void 0===b?(this._subscriptions[a].callbacks=[],b={}):"function"==typeof b?(f=this._subscriptions[a].callbacks.indexOf(b),b={onEvent:b}):f=this._subscriptions[a].callbacks.indexOf(b.onEvent),f>=0&&this._subscriptions[a].callbacks.splice(f,1),this._subscriptions[a].callbacks.length?(this._cache.opStatus=d.SUCCESS,this):(this._requests[e]={topic:a,callbacks:b},this._send([c.UNSUBSCRIBE,e,this._subscriptions[a].id]),this._cache.opStatus=d.SUCCESS,this)):(this._cache.opStatus=d.NON_EXIST_UNSUBSCRIBE,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this)},e.prototype.publish=function(a,b,e,f){var g,h,i={},j=!1;if(this._cache.sessionId&&!this._cache.server_wamp_features.roles.broker)return this._cache.opStatus=d.NO_BROKER,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;if(!this._validateURI(a))return this._cache.opStatus=d.URI_ERROR,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;if(this._isPlainObject(e)&&(i.acknowledge=!0),void 0!==f&&(this._isPlainObject(f)?(f.exclude&&(this._isArray(f.exclude)?i.exclude=f.exclude:"number"==typeof f.exclude?i.exclude=[f.exclude]:j=!0),f.eligible&&(this._isArray(f.eligible)?i.eligible=f.eligible:"number"==typeof f.eligible?i.eligible=[f.eligible]:j=!0),f.hasOwnProperty("exclude_me")&&(i.exclude_me=f.exclude_me!==!1),f.hasOwnProperty("disclose_me")&&(i.disclose_me=f.disclose_me===!0)):j=!0,j))return this._cache.opStatus=d.INVALID_PARAM,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;switch(g=this._getReqId(),arguments.length){case 1:h=[c.PUBLISH,g,i,a];break;case 2:h=this._isArray(b)?[c.PUBLISH,g,i,a,b]:this._isPlainObject(b)?[c.PUBLISH,g,i,a,[],b]:[c.PUBLISH,g,i,a,[b]];break;default:this._requests[g]={topic:a,callbacks:e},h=this._isArray(b)?[c.PUBLISH,g,i,a,b]:this._isPlainObject(b)?[c.PUBLISH,g,i,a,[],b]:[c.PUBLISH,g,i,a,[b]]}return this._send(h),this._cache.opStatus=d.SUCCESS,this},e.prototype.call=function(a,b,e,f){var g,h,i={},j=!1;if(this._cache.sessionId&&!this._cache.server_wamp_features.roles.dealer)return this._cache.opStatus=d.NO_DEALER,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;if(!this._validateURI(a))return this._cache.opStatus=d.URI_ERROR,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;if("function"==typeof e)e={onSuccess:e};else if(!this._isPlainObject(e)||void 0===e.onSuccess)return this._cache.opStatus=d.NO_CALLBACK_SPEC,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;if(void 0!==f&&(this._isPlainObject(f)?(f.exclude&&(this._isArray(f.exclude)?i.exclude=f.exclude:"number"==typeof f.exclude?i.exclude=[f.exclude]:j=!0),f.eligible&&(this._isArray(f.eligible)?i.eligible=f.eligible:"number"==typeof f.eligible?i.eligible=[f.eligible]:j=!0),f.hasOwnProperty("exclude_me")&&(i.exclude_me=f.exclude_me!==!1),f.hasOwnProperty("disclose_me")&&(i.disclose_me=f.disclose_me===!0)):j=!0,j))return this._cache.opStatus=d.INVALID_PARAM,this._isPlainObject(e)&&e.onError&&e.onError(this._cache.opStatus.description),this;do g=this._getReqId();while(g in this._calls);return this._calls[g]=e,h=null===b?[c.CALL,g,i,a]:this._isArray(b)?[c.CALL,g,i,a,b]:this._isPlainObject(b)?[c.CALL,g,i,a,[],b]:[c.CALL,g,i,a,[b]],this._send(h),this._cache.opStatus=d.SUCCESS,this},e.prototype.register=function(a,b){var e;if(this._cache.sessionId&&!this._cache.server_wamp_features.roles.dealer)return this._cache.opStatus=d.NO_DEALER,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;if(!this._validateURI(a))return this._cache.opStatus=d.URI_ERROR,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;if("function"==typeof b)b={rpc:b};else if(!this._isPlainObject(b)||void 0===b.rpc)return this._cache.opStatus=d.NO_CALLBACK_SPEC,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this;return this._rpcRegs[a]?(this._cache.opStatus=d.RPC_ALREADY_REGISTERED,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description)):(e=this._getReqId(),this._requests[e]={topic:a,callbacks:b},this._send([c.REGISTER,e,{},a]),this._cache.opStatus=d.SUCCESS),this},e.prototype.unregister=function(a,b){var e;return this._cache.sessionId&&!this._cache.server_wamp_features.roles.dealer?(this._cache.opStatus=d.NO_DEALER,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this):this._validateURI(a)?("function"==typeof b&&(b={onSuccess:b}),this._rpcRegs[a]?(e=this._getReqId(),this._requests[e]={topic:a,callbacks:b},this._send([c.UNREGISTER,e,this._rpcRegs[a].id]),this._cache.opStatus=d.SUCCESS):(this._cache.opStatus=d.RPC_ALREADY_REGISTERED,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description)),this):(this._cache.opStatus=d.URI_ERROR,this._isPlainObject(b)&&b.onError&&b.onError(this._cache.opStatus.description),this)},e}); \ No newline at end of file diff --git a/package.json b/package.json index 67cb112..0452e33 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,10 @@ "author": "Konstantin Burkalev (http://ksdaemon.ru)", "devDependencies": { "grunt": "~0.4.4", - "grunt-contrib-uglify": "^0.4.0", + "grunt-contrib-concat": "^0.5.0", + "grunt-contrib-copy": "^0.7.0", "grunt-contrib-jshint": "^0.10.0", - "grunt-contrib-copy": "^0.5.0" + "grunt-contrib-uglify": "^0.4.0" }, "main": "wampy.js", "dependencies": {