Socket
Socket
Sign inDemoInstall

engine.io

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

engine.io - npm Package Compare versions

Comparing version 0.3.10 to 0.4.1

12

History.md
0.4.1 / 2013-01-18
==================
* package: bumped versions
* Fixed bugs in previous send callback fix and updated test cases
* Added a test case which makes the code before the send callback fix fail
* socket: emit `data` event (synonym with `message`)
* socket: added `Socket#write`
* engine.io: cleanup
* engine.io: deprecated `resource`
* `npm docs engine.io` works now
0.3.10 / 2012-12-03

@@ -3,0 +15,0 @@ ===================

25

lib/engine.io.js

@@ -54,3 +54,3 @@ /**

exports.parser = require('./parser');
exports.parser = require('engine.io-parser');

@@ -100,6 +100,5 @@ /**

var path = (options.path || '/engine.io').replace(/\/$/, '');
var resource = options.resource || 'default';
// normalize path
path += '/' + resource + '/';
path += '/';

@@ -111,18 +110,8 @@ function check (req) {

// cache and clean up listeners
var listeners = server.listeners('request');
var oldListeners = [];
// copy the references onto a new array for node >=0.7
for (var i = 0, l = listeners.length; i < l; i++) {
oldListeners[i] = listeners[i];
}
var listeners = server.listeners('request').slice(0);
server.removeAllListeners('request');
server.on('close', engine.close.bind(engine));
server.on('close', function () {
engine.close();
});
// add request handler
server.on('request', function (req, res) {
server.on('request', function(req, res){
if (check(req)) {

@@ -132,4 +121,4 @@ debug('intercepting request for path "%s"', path);

} else {
for (var i = 0, l = oldListeners.length; i < l; i++) {
oldListeners[i].call(server, req, res);
for (var i = 0, l = listeners.length; i < l; i++) {
listeners[i].call(server, req, res);
}

@@ -136,0 +125,0 @@ }

@@ -27,2 +27,3 @@ /**

this.packetsFn = [];
this.sentCallbackFn = [];

@@ -101,3 +102,4 @@ this.setTransport(transport);

case 'message':
this.emit('message', null == packet.data ? '' : packet.data);
this.emit('data', packet.data);
this.emit('message', packet.data);
break;

@@ -230,2 +232,3 @@ }

this.packetsFn = [];
this.sentCallbackFn = [];
this.clearTransport();

@@ -247,7 +250,14 @@ this.readyState = 'closed';

this.transport.on('drain', function() {
if (self.packetsFn.length > 0) {
var seqFn = self.packetsFn.splice(0,1)[0];
if (self.sentCallbackFn.length > 0) {
var seqFn = self.sentCallbackFn.splice(0,1)[0];
if ('function' == typeof seqFn) {
debug('executing send callback');
seqFn(self.transport);
} else if (Array.isArray(seqFn)) {
debug('executing batch send callback');
for (var i in seqFn) {
if ('function' == typeof seqFn[i]) {
seqFn[i](self.transport);
}
}
}

@@ -267,3 +277,4 @@ }

Socket.prototype.send = function (data, callback) {
Socket.prototype.send =
Socket.prototype.write = function(data, callback){
this.sendPacket('message', data, callback);

@@ -294,5 +305,4 @@ return this;

//add send callback to object
if (callback) {
this.packetsFn.push(callback);
}
this.packetsFn.push(callback);
this.flush();

@@ -316,2 +326,8 @@ }

this.writeBuffer = [];
if (!this.transport.supportsFraming) {
this.sentCallbackFn.push(this.packetsFn)
} else {
this.sentCallbackFn.push.apply(this.sentCallbackFn, this.packetsFn);
}
this.packetsFn = [];
this.transport.send(wbuf);

@@ -318,0 +334,0 @@ this.emit('drain');

@@ -7,3 +7,3 @@

var EventEmitter = require('events').EventEmitter
, parser = require('./parser')
, parser = require('engine.io-parser')
, debug = require('debug')('engine:transport');

@@ -10,0 +10,0 @@

@@ -40,2 +40,10 @@

/**
* Advertise framing support.
*
* @api public
*/
FlashSocket.prototype.supportsFraming = true;
/**
* Listens for new configuration changes of the Manager

@@ -42,0 +50,0 @@ * this way we can enable and disable the flash server.

@@ -7,3 +7,3 @@

var Transport = require('../transport')
, parser = require('../parser')
, parser = require('engine.io-parser')
, debug = require('debug')('engine:polling')

@@ -10,0 +10,0 @@

@@ -7,3 +7,3 @@

var Transport = require('../transport')
, parser = require('../parser')
, parser = require('engine.io-parser')
, debug = require('debug')('engine:ws')

@@ -60,2 +60,10 @@

/**
* Advertise framing support.
*
* @api public
*/
WebSocket.prototype.supportsFraming = true;
/**
* Processes the incoming data.

@@ -78,16 +86,28 @@ *

*/
WebSocket.prototype.send = function (packets) {
for (var i = 0, l = packets.length; i < l; i++) {
var data = parser.encodePacket(packets[i]);
debug('writing "%s"', data);
this.writable = false;
var isIOS = 'undefined' != typeof navigator
&& /iPad|iPhone|iPod/i.test(navigator.userAgent)
WebSocket.prototype.send = function (data){
function send(packets){
for (var i = 0, l = packets.length; i < l; i++) {
var data = parser.encodePacket(packets[i]);
debug('writing "%s"', data);
this.writable = false;
var self = this;
this.socket.send(data, function (err){
if (err) return self.onError('write error', err.stack);
self.writable = true;
self.emit('drain');
});
}
}
// see https://github.com/LearnBoost/socket.io-client/pull/426
if (isIOS) {
var self = this;
this.socket.send(data, function (err){
if (err) return self.onError('write error', err.stack);
self.writable = true;
self.emit('drain');
});
setTimeout(function() {
send.call(self, data);
}, 0);
} else {
send.call(this, data);
}
};
}

@@ -94,0 +114,0 @@ /**

{
"name": "engine.io"
, "version": "0.3.10"
, "version": "0.4.1"
, "description": "The realtime engine behind Socket.IO. Provides the foundation of a bidirectional connection between client and server"
, "main": "./lib/engine.io"
, "author": "Guillermo Rauch <guillermo@learnboost.com>"
, "homepage": "https://github.com/LearnBoost/engine.io"
, "repository" : {
"type" : "git"
, "url" : "git://github.com/LearnBoost/engine.io.git"
}
, "contributors": [

@@ -15,3 +20,3 @@ { "name": "Eugen Dueck", "web": "https://github.com/EugenDueck" },

, "ws": "~0.4.21"
, "engine.io-client": "0.3.10"
, "engine.io-parser": "0.1.1"
, "base64id": "0.1.0"

@@ -23,2 +28,3 @@ }

, "superagent": "*"
, "engine.io-client": "0.4.1"
, "ws": "*"

@@ -28,2 +34,6 @@ , "s": "*"

, "scripts" : { "test" : "make test" }
, "repository": {
"type": "git"
, "url": "git@github.com:LearnBoost/engine.io.git"
}
}

@@ -75,3 +75,3 @@ # Engine.IO: the realtime engine

- **Isomorphic with WebSocket.IO**. You can switch between a WebSocket server
and a multi-transport server by chaning the `require`.
and a multi-transport server by changing the `require`.
- **Maximum reliability**. Connections are established even in the presence of:

@@ -137,5 +137,3 @@ - proxies and load balancers.

- **Options**
- `resource` (`String`): name of resource for this server (`default`).
Setting a resource allows you to initialize multiple engine.io
endpoints on the same host without them interfering.
- `path` (`String`): name of the path to capture (`/engine.io`).
- `policyFile` (`Boolean`): whether to handle policy file requests (`true`)

@@ -142,0 +140,0 @@ - `destroyUpgrade` (`Boolean`): destroy unhandled upgrade requests (`true`)

@@ -23,3 +23,3 @@ /*global eio,listen,request,expect*/

var version = require('../package').version;
expect(version).to.be(require('engine.io-client').version);
expect(version).to.be(require('engine.io-client/package').version);
});

@@ -26,0 +26,0 @@

@@ -8,4 +8,3 @@ /*global eio,eioc,listen,request,expect*/

var http = require('http')
, parser = eio.parser
, WebSocket = require('ws');
WebSocket = require('ws');

@@ -557,3 +556,3 @@ /**

'after `pingInterval + pingTimeout`', function (done) {
var opts = { allowUpgrades: false, pingInterval: 30, pingTimeout: 10 };
var opts = { allowUpgrades: false, pingInterval: 300, pingTimeout: 100 };
var engine = listen(opts, function (port) {

@@ -574,10 +573,10 @@ var socket = new eioc.Socket('ws://localhost:%d'.s(port));

expect(clientCloseReason).to.be(null);
}, 15);
}, 150);
setTimeout(function() {
expect(clientCloseReason).to.be(null);
}, 35);
}, 350);
setTimeout(function() {
expect(clientCloseReason).to.be("ping timeout");
done();
}, 50);
}, 500);
});

@@ -889,2 +888,39 @@ });

it('should execute in multipart packet (polling)', function (done) {
var engine = listen(function (port) {
var socket = new eioc.Socket('ws://localhost:%d'.s(port), { transports: ['polling'] });
var i = 0;
var j = 0;
engine.on('connection', function (conn) {
conn.send('d', function (transport) {
i++;
});
conn.send('c', function (transport) {
i++;
});
conn.send('b', function (transport) {
i++;
});
conn.send('a', function (transport) {
i++;
});
});
socket.on('open', function () {
socket.on('message', function (msg) {
j++;
});
});
setTimeout(function () {
expect(i).to.be(j);
done();
}, 200);
});
});
it('should clean callback references when socket gets closed with pending callbacks', function (done) {

@@ -910,2 +946,3 @@ var engine = listen({ allowUpgrades: false }, function (port) {

expect(conn.packetsFn).to.be.empty();
expect(conn.sentCallbackFn).to.be.empty();
done();

@@ -916,2 +953,25 @@ });

});
it('should not execute when it is not actually sent (polling)', function (done) {
var engine = listen({ allowUpgrades: false }, function (port) {
var socket = new eioc.Socket('ws://localhost:%d'.s(port), { transports: ['polling'] });
socket.transport.on('pollComplete', function(msg) {
socket.close();
});
engine.on('connection', function (conn) {
var err = undefined;
conn.send('a');
conn.send('b', function (transport) {
err = new Error('Test invalidation');
});
conn.on('close', function (reason) {
done(err);
});
});
});
});
});

@@ -918,0 +978,0 @@ });

Sorry, the diff of this file is not supported yet

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