Socket
Socket
Sign inDemoInstall

faye-websocket

Package Overview
Dependencies
4
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.8.1 to 0.9.0

CHANGELOG.md

43

examples/autobahn_client.js
var WebSocket = require('../lib/faye/websocket'),
deflate = require('permessage-deflate'),
pace = require('pace');
var host = 'ws://localhost:9001',
agent = 'node-' + process.version,
cases = 0,
skip = [];
var host = 'ws://localhost:9001',
agent = encodeURIComponent('node-' + process.version),
cases = 0,
options = {extensions: [deflate]};
var socket = new WebSocket.Client(host + '/getCaseCount'),
progress;
url, progress;

@@ -18,22 +19,22 @@ socket.onmessage = function(event) {

socket.onclose = function() {
var runCase = function(n) {
if (n > cases) {
socket = new WebSocket.Client(host + '/updateReports?agent=' + encodeURIComponent(agent));
socket.onclose = process.exit;
return;
}
progress.op();
var runCase = function(n) {
if (n > cases) {
url = host + '/updateReports?agent=' + agent;
socket = new WebSocket.Client(url);
socket.onclose = process.exit;
return;
}
if (skip.indexOf(n) >= 0) {
runCase(n + 1);
url = host + '/runCase?case=' + n + '&agent=' + agent;
socket = new WebSocket.Client(url, null, options);
socket.pipe(socket);
} else {
socket = new WebSocket.Client(host + '/runCase?case=' + n + '&agent=' + encodeURIComponent(agent));
socket.pipe(socket);
socket.on('close', function() { runCase(n + 1) });
}
};
socket.on('close', function() {
progress.op();
runCase(n + 1);
});
};
socket.onclose = function() {
runCase(1);
};
var WebSocket = require('../lib/faye/websocket'),
deflate = require('permessage-deflate'),
fs = require('fs'),

@@ -6,7 +7,8 @@ http = require('http'),

var port = process.argv[2] || 7000,
secure = process.argv[3] === 'tls';
var port = process.argv[2] || 7000,
secure = process.argv[3] === 'tls',
options = {extensions: [deflate], ping: 5};
var upgradeHandler = function(request, socket, head) {
var ws = new WebSocket(request, socket, head, ['irc', 'xmpp'], {ping: 5});
var ws = new WebSocket(request, socket, head, ['irc', 'xmpp'], options);
console.log('[open]', ws.url, ws.version, ws.protocol, request.headers);

@@ -13,0 +15,0 @@

// API references:
//
//
// * http://dev.w3.org/html5/websockets/

@@ -19,2 +19,3 @@ // * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-eventtarget

if (!this._stream || !this._stream.writable) return;
if (!this._stream.readable) return this._stream.end();

@@ -21,0 +22,0 @@ var catchup = function() { self._stream.removeListener('data', catchup) };

@@ -16,2 +16,7 @@ var Stream = require('stream').Stream,

var extensions = options.extensions;
if (extensions) {
[].concat(extensions).forEach(this._driver.addExtension, this._driver);
}
this._ping = options.ping;

@@ -138,10 +143,4 @@ this._pingId = 0;

if (this._pingTimer) clearInterval(this._pingTimer);
if (this._stream) this._stream.end();
var stream = this._stream;
if (stream) {
if (stream.unpipe) stream.unpipe(this._driver.io);
stream.on('data', function() { stream.destroy() });
stream.end();
}
if (this.readable) this.emit('end');

@@ -148,0 +147,0 @@ this.readable = this.writable = false;

@@ -8,7 +8,7 @@ { "name" : "faye-websocket"

, "version" : "0.8.1"
, "version" : "0.9.0"
, "engines" : {"node": ">=0.4.0"}
, "main" : "./lib/faye/websocket"
, "dependencies" : {"websocket-driver": ">=0.4.0"}
, "devDependencies" : {"jstest": "", "pace": ""}
, "dependencies" : {"websocket-driver": ">=0.5.0"}
, "devDependencies" : {"jstest": "", "pace": "", "permessage-deflate": ""}

@@ -15,0 +15,0 @@ , "scripts" : {"test": "jstest spec/runner.js"}

@@ -160,2 +160,18 @@ # faye-websocket

## Protocol extensions
faye-websocket is based on the
[websocket-extensions](https://github.com/faye/websocket-extensions-node)
framework that allows extensions to be negotiated via the
`Sec-WebSocket-Extensions` header. To add extensions to a connection, pass an
array of extensions to the `:extensions` option. For example, to add
[permessage-deflate](https://github.com/faye/permessage-deflate-node):
```js
var deflate = require('permessage-deflate');
var ws = new WebSocket(request, null, {extensions: [deflate]});
```
## Initialization options

@@ -174,2 +190,5 @@

* `extensions` - an array of
[websocket-extensions](https://github.com/faye/websocket-extensions-node)
compatible extensions, as described above
* `headers` - an object containing key-value pairs representing HTTP headers to

@@ -176,0 +195,0 @@ be sent during the handshake process

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc