websocket-stream
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -12,3 +12,3 @@ | ||
module.exports.start = function(cb) { | ||
module.exports.start = function(opts, cb) { | ||
if (server) { | ||
@@ -19,5 +19,12 @@ cb(new Error('already started')); | ||
if (typeof opts == 'function') { | ||
cb = opts; | ||
opts = {}; | ||
} | ||
server = http.createServer() | ||
var wss = new WebSocketServer({server: server}) | ||
opts.server = server | ||
var wss = new WebSocketServer(opts) | ||
wss.on('connection', function(ws) { | ||
@@ -24,0 +31,0 @@ var stream = websocket(ws) |
@@ -22,3 +22,3 @@ var through = require('through') | ||
} else { | ||
this.ws = new WebSocketPoly(server, this.options.protocol) | ||
this.ws = new WebSocketPoly(server, this.options) | ||
this.ws.binaryType = this.options.binaryType || 'arraybuffer' | ||
@@ -25,0 +25,0 @@ this.ws.onmessage = this.onMessage.bind(this) |
{ | ||
"name": "websocket-stream", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "websockets with the node stream api. works in browser and node", | ||
@@ -5,0 +5,0 @@ "scripts": { |
26
test.js
@@ -46,1 +46,27 @@ var test = require('tape') | ||
}); | ||
test('passes options to websocket constructor', function(t) { | ||
t.plan(2) | ||
opts = { | ||
verifyClient: function verifyClient(info) { | ||
t.equal(info.req.headers['x-custom-header'], 'Custom Value') | ||
return true | ||
} | ||
} | ||
echo.start(opts, function() { | ||
var options = {headers: {'x-custom-header': 'Custom Value'}} | ||
var client = websocket(echo.url, options) | ||
client.on('error', console.error) | ||
client.on('data', function(data) { | ||
t.equal(data, 'hello world') | ||
client.end() | ||
echo.stop(function() {}) | ||
}) | ||
client.write('hello world') | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11610
217