diff --git a/package.json b/package.json index a1900a4..cd456bb 100644 --- a/package.json +++ b/package.json @@ -23,15 +23,15 @@ "email": "max@maxogden.com" }, "dependencies": { - "duplexify": "^3.6.1", + "duplexify": "^3.5.1", "inherits": "^2.0.1", - "readable-stream": "^3.0.0", + "readable-stream": "^2.3.3", "safe-buffer": "^5.1.2", - "ws": "^6.1.2", + "ws": "^3.2.0", "xtend": "^4.0.0" }, "devDependencies": { - "beefy": "^2.1.1", + "beefy": "^2.1.8", "browserify": "^16.2.3", "concat-stream": "^1.6.2", "tape": "^4.9.1" diff --git a/stream.js b/stream.js index d138eea..fbbb1b6 100644 --- a/stream.js +++ b/stream.js @@ -73,7 +73,10 @@ function WebSocketStream(target, protocols, options) { if (socket.readyState === socket.OPEN) { stream = proxy } else { - stream = duplexify.obj() + stream = stream = duplexify(undefined, undefined, options) + if (!options.objectMode) { + stream._writev = writev + } socket.onopen = onopen } diff --git a/test-client.js b/test-client.js index b5ada2c..a2c75fd 100644 --- a/test-client.js +++ b/test-client.js @@ -59,3 +59,16 @@ test('coerce client data as binary', function(t) { }) stream.write('hello') }) +test('cork logic test', function (t) { + var stream = ws('ws://localhost:8343', { binary: true }) + stream.on('data', function(o) { + t.equal(o.toString(), 'hello', 'success!') + stream.destroy() + t.end() + }) + stream.cork() + stream.write('he') + stream.write('l') + stream.write('lo') + stream.uncork() +}) \ No newline at end of file