Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

websocket-stream

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

websocket-stream - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

11

echo-server.js

@@ -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)

2

index.js

@@ -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": {

@@ -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')
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc