diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..7dccd97 --- /dev/null +++ b/.npmignore @@ -0,0 +1,15 @@ +lib-cov +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz + +pids +logs +results + +node_modules +npm-debug.log \ No newline at end of file diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 9ab8a65..ed32786 --- a/README.md +++ b/README.md @@ -35,6 +35,10 @@ Client ## Changelog +0.2.2 + +- Update js-binarypack to 0.0.9, removed unused check. + 0.2.1 - Update js-binarypack to 0.0.7, fast utf8 support now on by default. diff --git a/bin/build.js b/bin/build.js old mode 100644 new mode 100755 index 46fdf0c..415a8b3 --- a/bin/build.js +++ b/bin/build.js @@ -38,8 +38,7 @@ var starttagIF = '// if node' */ var base = [ - '../deps/js-binarypack/lib/bufferbuilder.js' - , '../deps/js-binarypack/lib/binarypack.js' + '../deps/js-binarypack/dist/binarypack.js' , '../deps/EventEmitter/EventEmitter.js' , 'util.js' , 'client/stream.js' diff --git a/dist/binary.js b/dist/binary.js old mode 100644 new mode 100755 index ef22991..ca2f648 --- a/dist/binary.js +++ b/dist/binary.js @@ -1,79 +1,10 @@ -/*! binary.js build:0.2.1, development. Copyright(c) 2012 Eric Zhang MIT Licensed */ +/*! binary.js build:0.2.2, development. Copyright(c) 2012 Eric Zhang MIT Licensed */ (function(exports){ -var binaryFeatures = {}; -binaryFeatures.useBlobBuilder = (function(){ - try { - new Blob([]); - return false; - } catch (e) { - return true; - } -})(); +/*! binarypack.js build:0.0.9, production. Copyright(c) 2012 Eric Zhang MIT Licensed */(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 0) { - var buf = new Uint8Array(this._pieces); - if(!binaryFeatures.useArrayBufferView) { - buf = buf.buffer; - } - this._parts.push(buf); - this._pieces = []; - } -}; - -BufferBuilder.prototype.getBuffer = function() { - this.flush(); - if(binaryFeatures.useBlobBuilder) { - var builder = new BlobBuilder(); - for(var i = 0, ii = this._parts.length; i < ii; i++) { - builder.append(this._parts[i]); - } - return builder.getBlob(); - } else { - return new Blob(this._parts); - } -}; -exports.BinaryPack = { +var BinaryPack = { unpack: function(data){ var unpacker = new Unpacker(data); return unpacker.unpack(); @@ -86,6 +17,8 @@ exports.BinaryPack = { } }; +module.exports = BinaryPack; + function Unpacker (data){ // Data is ArrayBuffer this.index = 0; @@ -94,7 +27,6 @@ function Unpacker (data){ this.length = this.dataBuffer.byteLength; } - Unpacker.prototype.unpack = function(){ var type = this.unpack_uint8(); if (type < 0x80){ @@ -400,7 +332,6 @@ Packer.prototype.pack_bin = function(blob){ this.pack_uint32(length); } else{ throw new Error('Invalid length'); - return; } this.bufferBuilder.append(blob); } @@ -418,7 +349,6 @@ Packer.prototype.pack_string = function(str){ this.pack_uint32(length); } else{ throw new Error('Invalid length'); - return; } this.bufferBuilder.append(str); } @@ -590,6 +520,82 @@ function utf8Length(str){ return str.replace(/[^\u0000-\u007F]/g, _utf8Replace).length; } } + +},{"./bufferbuilder":2}],2:[function(require,module,exports){ +var binaryFeatures = {}; +binaryFeatures.useBlobBuilder = (function(){ + try { + new Blob([]); + return false; + } catch (e) { + return true; + } +})(); + +binaryFeatures.useArrayBufferView = !binaryFeatures.useBlobBuilder && (function(){ + try { + return (new Blob([new Uint8Array([])])).size === 0; + } catch (e) { + return true; + } +})(); + +module.exports.binaryFeatures = binaryFeatures; +var BlobBuilder = module.exports.BlobBuilder; +if (typeof window != 'undefined') { + BlobBuilder = module.exports.BlobBuilder = window.WebKitBlobBuilder || + window.MozBlobBuilder || window.MSBlobBuilder || window.BlobBuilder; +} + +function BufferBuilder(){ + this._pieces = []; + this._parts = []; +} + +BufferBuilder.prototype.append = function(data) { + if(typeof data === 'number') { + this._pieces.push(data); + } else { + this.flush(); + this._parts.push(data); + } +}; + +BufferBuilder.prototype.flush = function() { + if (this._pieces.length > 0) { + var buf = new Uint8Array(this._pieces); + if(!binaryFeatures.useArrayBufferView) { + buf = buf.buffer; + } + this._parts.push(buf); + this._pieces = []; + } +}; + +BufferBuilder.prototype.getBuffer = function() { + this.flush(); + if(binaryFeatures.useBlobBuilder) { + var builder = new BlobBuilder(); + for(var i = 0, ii = this._parts.length; i < ii; i++) { + builder.append(this._parts[i]); + } + return builder.getBlob(); + } else { + return new Blob(this._parts); + } +}; + +module.exports.BufferBuilder = BufferBuilder; + +},{}],3:[function(require,module,exports){ +var BufferBuilderExports = require('./bufferbuilder'); + +window.BufferBuilder = BufferBuilderExports.BufferBuilder; +window.binaryFeatures = BufferBuilderExports.binaryFeatures; +window.BlobBuilder = BufferBuilderExports.BlobBuilder; +window.BinaryPack = require('./binarypack'); + +},{"./binarypack":1,"./bufferbuilder":2}]},{},[3]); /** * Light EventEmitter. Ported from Node.js/events.js * Eric Zhang @@ -805,6 +811,7 @@ var util = { }(this)) }; +exports.util = util; function Stream() { @@ -897,6 +904,8 @@ Stream.prototype.pipe = function(dest, options) { // Allow for unix-like usage: A.pipe(B).pipe(C) return dest; }; + +exports.Stream = Stream; function BlobReadStream(source, options){ Stream.call(this); @@ -1280,7 +1289,8 @@ BinaryStream.prototype.write = function(data) { var out = this._write(2, data, this.id); return !this.paused && out; } else { - throw new Error('Stream is not writable'); + this.emit('error', new Error('Stream is not writable')); + return false; } }; diff --git a/dist/binary.min.js b/dist/binary.min.js old mode 100644 new mode 100755 index 1887d21..6517381 --- a/dist/binary.min.js +++ b/dist/binary.min.js @@ -1 +1 @@ -/*! binary.min.js build:0.2.1, production. Copyright(c) 2012 Eric Zhang MIT Licensed */(function(e){function n(){this._pieces=[],this._parts=[]}function r(e){this.index=0,this.dataBuffer=e,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}function i(){this.bufferBuilder=new n}function s(e){var t=e.charCodeAt(0);return t<=2047?"00":t<=65535?"000":t<=2097151?"0000":t<=67108863?"00000":"000000"}function o(e){return e.length>600?(new Blob([e])).size:e.replace(/[^\u0000-\u007F]/g,s).length}function u(){this._events={}}function l(){u.call(this)}function c(e,t){l.call(this),t=f.extend({readDelay:0,paused:!1},t),this._source=e,this._start=0,this._readChunkSize=t.chunkSize||e.size,this._readDelay=t.readDelay,this.readable=!0,this.paused=t.paused,this._read()}function h(e,t,n,r){if(!(this instanceof h))return new h(options);var i=this;l.call(this),this.id=t,this._socket=e,this.writable=!0,this.readable=!0,this.paused=!1,this._closed=!1,this._ended=!1,n&&this._write(1,r,this.id)}function p(e,t){if(!(this instanceof p))return new p(e,t);u.call(this);var n=this;this._options=f.extend({chunkSize:40960},t),this.streams={},typeof e=="string"?(this._nextId=0,this._socket=new WebSocket(e)):(this._nextId=1,this._socket=e),this._socket.binaryType="arraybuffer",this._socket.addEventListener("open",function(){n.emit("open")}),this._socket.addEventListener("error",function(e){var t=Object.keys(n.streams);for(var r=0,i=t.length;r0){var e=new Uint8Array(this._pieces);t.useArrayBufferView||(e=e.buffer),this._parts.push(e),this._pieces=[]}},n.prototype.getBuffer=function(){this.flush();if(t.useBlobBuilder){var e=new BlobBuilder;for(var n=0,r=this._parts.length;n>31,n=(e>>23&255)-127,r=e&8388607|8388608;return(t==0?1:-1)*r*Math.pow(2,n-23)},r.prototype.unpack_double=function(){var e=this.unpack_uint32(),t=this.unpack_uint32(),n=e>>31,r=(e>>20&2047)-1023,i=e&1048575|1048576,s=i*Math.pow(2,r-20)+t*Math.pow(2,r-52);return(n==0?1:-1)*s},r.prototype.read=function(e){var t=this.index;if(t+e<=this.length)return this.dataView.subarray(t,t+e);throw new Error("BinaryPackFailure: read index out of range")},i.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},i.prototype.pack=function(e){var n=typeof e;if(n=="string")this.pack_string(e);else if(n=="number")Math.floor(e)===e?this.pack_integer(e):this.pack_double(e);else if(n=="boolean")e===!0?this.bufferBuilder.append(195):e===!1&&this.bufferBuilder.append(194);else if(n=="undefined")this.bufferBuilder.append(192);else{if(n!="object")throw new Error('Type "'+n+'" not yet supported');if(e===null)this.bufferBuilder.append(192);else{var r=e.constructor;if(r==Array)this.pack_array(e);else if(r==Blob||r==File)this.pack_bin(e);else if(r==ArrayBuffer)t.useArrayBufferView?this.pack_bin(new Uint8Array(e)):this.pack_bin(e);else if("BYTES_PER_ELEMENT"in e)t.useArrayBufferView?this.pack_bin(new Uint8Array(e.buffer)):this.pack_bin(e.buffer);else if(r==Object)this.pack_object(e);else if(r==Date)this.pack_string(e.toString());else{if(typeof e.toBinaryPack!="function")throw new Error('Type "'+r.toString()+'" not yet supported');this.bufferBuilder.append(e.toBinaryPack())}}}this.bufferBuilder.flush()},i.prototype.pack_bin=function(e){var t=e.length||e.byteLength||e.size;if(t<=15)this.pack_uint8(160+t);else if(t<=65535)this.bufferBuilder.append(218),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(219),this.pack_uint32(t)}this.bufferBuilder.append(e)},i.prototype.pack_string=function(e){var t=o(e);if(t<=15)this.pack_uint8(176+t);else if(t<=65535)this.bufferBuilder.append(216),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(217),this.pack_uint32(t)}this.bufferBuilder.append(e)},i.prototype.pack_array=function(e){var t=e.length;if(t<=15)this.pack_uint8(144+t);else if(t<=65535)this.bufferBuilder.append(220),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(221),this.pack_uint32(t)}for(var n=0;n>8),this.bufferBuilder.append(e&255)},i.prototype.pack_uint32=function(e){var t=e&4294967295;this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255)},i.prototype.pack_uint64=function(e){var t=e/Math.pow(2,32),n=e%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((n&4278190080)>>>24),this.bufferBuilder.append((n&16711680)>>>16),this.bufferBuilder.append((n&65280)>>>8),this.bufferBuilder.append(n&255)},i.prototype.pack_int8=function(e){this.bufferBuilder.append(e&255)},i.prototype.pack_int16=function(e){this.bufferBuilder.append((e&65280)>>8),this.bufferBuilder.append(e&255)},i.prototype.pack_int32=function(e){this.bufferBuilder.append(e>>>24&255),this.bufferBuilder.append((e&16711680)>>>16),this.bufferBuilder.append((e&65280)>>>8),this.bufferBuilder.append(e&255)},i.prototype.pack_int64=function(e){var t=Math.floor(e/Math.pow(2,32)),n=e%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((n&4278190080)>>>24),this.bufferBuilder.append((n&16711680)>>>16),this.bufferBuilder.append((n&65280)>>>8),this.bufferBuilder.append(n&255)};var a=Array.isArray;u.prototype.addListener=function(e,t,n,r){if("function"!=typeof t)throw new Error("addListener only takes instances of Function");this.emit("newListener",e,typeof t.listener=="function"?t.listener:t),this._events[e]?a(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t},u.prototype.on=u.prototype.addListener,u.prototype.once=function(e,t,n){function i(){r.removeListener(e,i),t.apply(this,arguments)}if("function"!=typeof t)throw new Error(".once only takes instances of Function");var r=this;return i.listener=t,r.on(e,i),this},u.prototype.removeListener=function(e,t,n){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");if(!this._events[e])return this;var r=this._events[e];if(a(r)){var i=-1;for(var s=0,o=r.length;s MIT Licensed */(function(e){function t(){this._events={}}function i(){t.call(this)}function s(e,t){i.call(this),t=r.extend({readDelay:0,paused:!1},t),this._source=e,this._start=0,this._readChunkSize=t.chunkSize||e.size,this._readDelay=t.readDelay,this.readable=!0,this.paused=t.paused,this._read()}function o(e,t,n,r){if(!(this instanceof o))return new o(options);var s=this;i.call(this),this.id=t,this._socket=e,this.writable=!0,this.readable=!0,this.paused=!1,this._closed=!1,this._ended=!1,n&&this._write(1,r,this.id)}function u(e,n){if(!(this instanceof u))return new u(e,n);t.call(this);var i=this;this._options=r.extend({chunkSize:40960},n),this.streams={},typeof e=="string"?(this._nextId=0,this._socket=new WebSocket(e)):(this._nextId=1,this._socket=e),this._socket.binaryType="arraybuffer",this._socket.addEventListener("open",function(){i.emit("open")}),this._socket.addEventListener("error",function(e){var t=Object.keys(i.streams);for(var n=0,r=t.length;n600?(new Blob([e])).size:e.replace(/[^\u0000-\u007F]/g,a).length}var r=e("./bufferbuilder").BufferBuilder,i=e("./bufferbuilder").binaryFeatures,s={unpack:function(e){var t=new o(e);return t.unpack()},pack:function(e){var t=new u;t.pack(e);var n=t.getBuffer();return n}};t.exports=s,o.prototype.unpack=function(){var e=this.unpack_uint8();if(e<128){var t=e;return t}if((e^224)<32){var n=(e^224)-32;return n}var r;if((r=e^160)<=15)return this.unpack_raw(r);if((r=e^176)<=15)return this.unpack_string(r);if((r=e^144)<=15)return this.unpack_array(r);if((r=e^128)<=15)return this.unpack_map(r);switch(e){case 192:return null;case 193:return undefined;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return undefined;case 213:return undefined;case 214:return undefined;case 215:return undefined;case 216:return r=this.unpack_uint16(),this.unpack_string(r);case 217:return r=this.unpack_uint32(),this.unpack_string(r);case 218:return r=this.unpack_uint16(),this.unpack_raw(r);case 219:return r=this.unpack_uint32(),this.unpack_raw(r);case 220:return r=this.unpack_uint16(),this.unpack_array(r);case 221:return r=this.unpack_uint32(),this.unpack_array(r);case 222:return r=this.unpack_uint16(),this.unpack_map(r);case 223:return r=this.unpack_uint32(),this.unpack_map(r)}},o.prototype.unpack_uint8=function(){var e=this.dataView[this.index]&255;return this.index++,e},o.prototype.unpack_uint16=function(){var e=this.read(2),t=(e[0]&255)*256+(e[1]&255);return this.index+=2,t},o.prototype.unpack_uint32=function(){var e=this.read(4),t=((e[0]*256+e[1])*256+e[2])*256+e[3];return this.index+=4,t},o.prototype.unpack_uint64=function(){var e=this.read(8),t=((((((e[0]*256+e[1])*256+e[2])*256+e[3])*256+e[4])*256+e[5])*256+e[6])*256+e[7];return this.index+=8,t},o.prototype.unpack_int8=function(){var e=this.unpack_uint8();return e<128?e:e-256},o.prototype.unpack_int16=function(){var e=this.unpack_uint16();return e<32768?e:e-65536},o.prototype.unpack_int32=function(){var e=this.unpack_uint32();return e>31,n=(e>>23&255)-127,r=e&8388607|8388608;return(t==0?1:-1)*r*Math.pow(2,n-23)},o.prototype.unpack_double=function(){var e=this.unpack_uint32(),t=this.unpack_uint32(),n=e>>31,r=(e>>20&2047)-1023,i=e&1048575|1048576,s=i*Math.pow(2,r-20)+t*Math.pow(2,r-52);return(n==0?1:-1)*s},o.prototype.read=function(e){var t=this.index;if(t+e<=this.length)return this.dataView.subarray(t,t+e);throw new Error("BinaryPackFailure: read index out of range")},u.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},u.prototype.pack=function(e){var t=typeof e;if(t=="string")this.pack_string(e);else if(t=="number")Math.floor(e)===e?this.pack_integer(e):this.pack_double(e);else if(t=="boolean")e===!0?this.bufferBuilder.append(195):e===!1&&this.bufferBuilder.append(194);else if(t=="undefined")this.bufferBuilder.append(192);else{if(t!="object")throw new Error('Type "'+t+'" not yet supported');if(e===null)this.bufferBuilder.append(192);else{var n=e.constructor;if(n==Array)this.pack_array(e);else if(n==Blob||n==File)this.pack_bin(e);else if(n==ArrayBuffer)i.useArrayBufferView?this.pack_bin(new Uint8Array(e)):this.pack_bin(e);else if("BYTES_PER_ELEMENT"in e)i.useArrayBufferView?this.pack_bin(new Uint8Array(e.buffer)):this.pack_bin(e.buffer);else if(n==Object)this.pack_object(e);else if(n==Date)this.pack_string(e.toString());else{if(typeof e.toBinaryPack!="function")throw new Error('Type "'+n.toString()+'" not yet supported');this.bufferBuilder.append(e.toBinaryPack())}}}this.bufferBuilder.flush()},u.prototype.pack_bin=function(e){var t=e.length||e.byteLength||e.size;if(t<=15)this.pack_uint8(160+t);else if(t<=65535)this.bufferBuilder.append(218),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(219),this.pack_uint32(t)}this.bufferBuilder.append(e)},u.prototype.pack_string=function(e){var t=f(e);if(t<=15)this.pack_uint8(176+t);else if(t<=65535)this.bufferBuilder.append(216),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(217),this.pack_uint32(t)}this.bufferBuilder.append(e)},u.prototype.pack_array=function(e){var t=e.length;if(t<=15)this.pack_uint8(144+t);else if(t<=65535)this.bufferBuilder.append(220),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(221),this.pack_uint32(t)}for(var n=0;n>8),this.bufferBuilder.append(e&255)},u.prototype.pack_uint32=function(e){var t=e&4294967295;this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255)},u.prototype.pack_uint64=function(e){var t=e/Math.pow(2,32),n=e%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((n&4278190080)>>>24),this.bufferBuilder.append((n&16711680)>>>16),this.bufferBuilder.append((n&65280)>>>8),this.bufferBuilder.append(n&255)},u.prototype.pack_int8=function(e){this.bufferBuilder.append(e&255)},u.prototype.pack_int16=function(e){this.bufferBuilder.append((e&65280)>>8),this.bufferBuilder.append(e&255)},u.prototype.pack_int32=function(e){this.bufferBuilder.append(e>>>24&255),this.bufferBuilder.append((e&16711680)>>>16),this.bufferBuilder.append((e&65280)>>>8),this.bufferBuilder.append(e&255)},u.prototype.pack_int64=function(e){var t=Math.floor(e/Math.pow(2,32)),n=e%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((n&4278190080)>>>24),this.bufferBuilder.append((n&16711680)>>>16),this.bufferBuilder.append((n&65280)>>>8),this.bufferBuilder.append(n&255)}},{"./bufferbuilder":2}],2:[function(e,t,n){function s(){this._pieces=[],this._parts=[]}var r={};r.useBlobBuilder=function(){try{return new Blob([]),!1}catch(e){return!0}}(),r.useArrayBufferView=!r.useBlobBuilder&&function(){try{return(new Blob([new Uint8Array([])])).size===0}catch(e){return!0}}(),t.exports.binaryFeatures=r;var i=t.exports.BlobBuilder;typeof window!="undefined"&&(i=t.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder),s.prototype.append=function(e){typeof e=="number"?this._pieces.push(e):(this.flush(),this._parts.push(e))},s.prototype.flush=function(){if(this._pieces.length>0){var e=new Uint8Array(this._pieces);r.useArrayBufferView||(e=e.buffer),this._parts.push(e),this._pieces=[]}},s.prototype.getBuffer=function(){this.flush();if(r.useBlobBuilder){var e=new i;for(var t=0,n=this._parts.length;t=0.6.0" + "node": ">=0.10.20" }, "dependencies": { - "streamws": ">=0.1.1", + "ws": "git://github.com/carck/ws.git#0.8.1", "binarypack": ">=0.0.4", "streamers": ">=0.1.0" }, diff --git a/test/client.js b/test/client.js old mode 100644 new mode 100755 index 2d13b24..449336b --- a/test/client.js +++ b/test/client.js @@ -37,6 +37,21 @@ describe('BinaryClient', function(){ client.createStream(); }); }); + it('should receive notification', function(done){ + server.on('connection', function(client){ + client.on('stream', function(stream){ + stream.sendNotification("ready"); + }); + }); + var client = new BinaryClient(serverUrl); + client.on('open', function(){ + client.createStream().on('notify', function(event){ + if('ready' === event) { + done(); + } + }); + }); + }); }); describe('sending data', function(){