websocket-stream
Advanced tools
Comparing version 0.3.2 to 0.3.3
10
index.js
@@ -78,5 +78,9 @@ var stream = require('stream') | ||
WebsocketStream.prototype._write = function(data) { | ||
typeof WebSocket != 'undefined' && this.ws instanceof WebSocket | ||
? this.ws.send(data) | ||
: this.ws.send(data, { binary : isBuffer(data) }) | ||
if (this.ws.readyState == 1) | ||
// we are connected | ||
typeof WebSocket != 'undefined' && this.ws instanceof WebSocket | ||
? this.ws.send(data) | ||
: this.ws.send(data, { binary : isBuffer(data) }) | ||
else | ||
this.emit('error', 'Not connected') | ||
} | ||
@@ -83,0 +87,0 @@ |
{ | ||
"name": "websocket-stream", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "websockets with the node stream api. works in browser and node", | ||
@@ -5,0 +5,0 @@ "scripts": { |
22
test.js
@@ -24,1 +24,23 @@ var test = require('tape') | ||
}); | ||
test('emitting not connected errors', function(t) { | ||
echo.start(function() { | ||
var client = websocket(echo.url, echo.options) | ||
client.on('error', function() { | ||
echo.stop(function() { | ||
t.true(true, 'should emit error') | ||
t.end() | ||
}) | ||
}) | ||
client.once('data', function(data) { | ||
client.end() | ||
client.write('abcde') | ||
}) | ||
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
10990
198