engine.io-client
Advanced tools
Comparing version 0.3.9 to 0.3.10
@@ -130,3 +130,3 @@ (function(){var global = this; | ||
exports.version = '0.3.8'; | ||
exports.version = '0.3.10'; | ||
@@ -707,8 +707,12 @@ /** | ||
var transport = this.createTransport(name, { probe: 1 }) | ||
, failed = false | ||
, self = this; | ||
transport.once('open', function () { | ||
if (failed) return; | ||
debug('probe transport "%s" opened', name); | ||
transport.send([{ type: 'ping', data: 'probe' }]); | ||
transport.once('packet', function (msg) { | ||
if (failed) return; | ||
if ('pong' == msg.type && 'probe' == msg.data) { | ||
@@ -721,4 +725,8 @@ debug('probe transport "%s" pong', name); | ||
self.transport.pause(function () { | ||
if ('closed' == self.readyState || 'closing' == self.readyState) return; | ||
if (failed) return; | ||
if ('closed' == self.readyState || 'closing' == self.readyState) { | ||
return; | ||
} | ||
debug('changing transport and sending upgrade packet'); | ||
transport.removeListener('error', onerror); | ||
self.emit('upgrade', transport); | ||
@@ -740,2 +748,20 @@ self.setTransport(transport); | ||
transport.once('error', onerror); | ||
function onerror(err) { | ||
if (failed) return; | ||
// Any callback called by transport should be ignored since now | ||
failed = true; | ||
var error = new Error('probe error: ' + err); | ||
error.transport = transport.name; | ||
transport.close(); | ||
transport = null; | ||
debug('probe transport "%s" failed because of error: %s', name, err); | ||
self.emit('error', error); | ||
}; | ||
transport.open(); | ||
@@ -746,2 +772,3 @@ | ||
debug('socket closed prematurely - aborting probe'); | ||
failed = true; | ||
transport.close(); | ||
@@ -774,3 +801,5 @@ transport = null; | ||
if (this.upgrade && this.transport.pause) { | ||
// we check for `readyState` in case an `open` | ||
// listener alreay closed the socket | ||
if ('open' == this.readyState && this.upgrade && this.transport.pause) { | ||
debug('starting upgrade probes'); | ||
@@ -962,2 +991,4 @@ for (var i = 0, l = this.upgrades.length; i < l; i++) { | ||
debug('socket close with reason: "%s"', reason); | ||
clearTimeout(this.pingIntervalTimer); | ||
clearTimeout(this.pingTimeoutTimer); | ||
this.readyState = 'closed'; | ||
@@ -964,0 +995,0 @@ this.emit('close', reason, desc); |
@@ -9,3 +9,3 @@ (function(){var global = this;function debug(){return debug};function require(p, parent){ var path = require.resolve(p) , mod = require.modules[path]; if (!mod) throw new Error('failed to require "' + p + '" from ' + parent); if (!mod.exports) { mod.exports = {}; mod.call(mod.exports, mod, mod.exports, require.relative(path), global); } return mod.exports;}require.modules = {};require.resolve = function(path){ var orig = path , reg = path + '.js' , index = path + '/index.js'; return require.modules[reg] && reg || require.modules[index] && index || orig;};require.register = function(path, fn){ require.modules[path] = fn;};require.relative = function(parent) { return function(p){ if ('debug' == p) return debug; if ('.' != p.charAt(0)) return require(p); var path = parent.split('/') , segs = p.split('/'); path.pop(); for (var i = 0; i < segs.length; i++) { var seg = segs[i]; if ('..' == seg) path.pop(); else if ('.' != seg) path.push(seg); } return require(path.join('/'), parent); };};require.register("engine.io-client.js", function(module, exports, require, global){ | ||
exports.version = '0.3.8'; | ||
exports.version = '0.3.10'; | ||
@@ -586,8 +586,12 @@ /** | ||
var transport = this.createTransport(name, { probe: 1 }) | ||
, failed = false | ||
, self = this; | ||
transport.once('open', function () { | ||
if (failed) return; | ||
debug('probe transport "%s" opened', name); | ||
transport.send([{ type: 'ping', data: 'probe' }]); | ||
transport.once('packet', function (msg) { | ||
if (failed) return; | ||
if ('pong' == msg.type && 'probe' == msg.data) { | ||
@@ -600,4 +604,8 @@ debug('probe transport "%s" pong', name); | ||
self.transport.pause(function () { | ||
if ('closed' == self.readyState || 'closing' == self.readyState) return; | ||
if (failed) return; | ||
if ('closed' == self.readyState || 'closing' == self.readyState) { | ||
return; | ||
} | ||
debug('changing transport and sending upgrade packet'); | ||
transport.removeListener('error', onerror); | ||
self.emit('upgrade', transport); | ||
@@ -619,2 +627,20 @@ self.setTransport(transport); | ||
transport.once('error', onerror); | ||
function onerror(err) { | ||
if (failed) return; | ||
// Any callback called by transport should be ignored since now | ||
failed = true; | ||
var error = new Error('probe error: ' + err); | ||
error.transport = transport.name; | ||
transport.close(); | ||
transport = null; | ||
debug('probe transport "%s" failed because of error: %s', name, err); | ||
self.emit('error', error); | ||
}; | ||
transport.open(); | ||
@@ -625,2 +651,3 @@ | ||
debug('socket closed prematurely - aborting probe'); | ||
failed = true; | ||
transport.close(); | ||
@@ -653,3 +680,5 @@ transport = null; | ||
if (this.upgrade && this.transport.pause) { | ||
// we check for `readyState` in case an `open` | ||
// listener alreay closed the socket | ||
if ('open' == this.readyState && this.upgrade && this.transport.pause) { | ||
debug('starting upgrade probes'); | ||
@@ -841,2 +870,4 @@ for (var i = 0, l = this.upgrades.length; i < l; i++) { | ||
debug('socket close with reason: "%s"', reason); | ||
clearTimeout(this.pingIntervalTimer); | ||
clearTimeout(this.pingTimeoutTimer); | ||
this.readyState = 'closed'; | ||
@@ -843,0 +874,0 @@ this.emit('close', reason, desc); |
0.3.10 / 2012-12-03 | ||
=================== | ||
* socket: fix closing the socket in an `open` listener [mmastrac] | ||
* socket: perform ping interval/timer cleanup [mmastrac] | ||
* fix SPEC (packages -> packets) [jxck] | ||
* socket: handle probe's transport errors [indutny] | ||
0.3.9 / 2012-10-23 | ||
@@ -3,0 +11,0 @@ ================== |
@@ -8,3 +8,3 @@ | ||
exports.version = '0.3.9'; | ||
exports.version = '0.3.10'; | ||
@@ -11,0 +11,0 @@ /** |
@@ -168,8 +168,12 @@ /** | ||
var transport = this.createTransport(name, { probe: 1 }) | ||
, failed = false | ||
, self = this; | ||
transport.once('open', function () { | ||
if (failed) return; | ||
debug('probe transport "%s" opened', name); | ||
transport.send([{ type: 'ping', data: 'probe' }]); | ||
transport.once('packet', function (msg) { | ||
if (failed) return; | ||
if ('pong' == msg.type && 'probe' == msg.data) { | ||
@@ -182,4 +186,8 @@ debug('probe transport "%s" pong', name); | ||
self.transport.pause(function () { | ||
if ('closed' == self.readyState || 'closing' == self.readyState) return; | ||
if (failed) return; | ||
if ('closed' == self.readyState || 'closing' == self.readyState) { | ||
return; | ||
} | ||
debug('changing transport and sending upgrade packet'); | ||
transport.removeListener('error', onerror); | ||
self.emit('upgrade', transport); | ||
@@ -201,2 +209,20 @@ self.setTransport(transport); | ||
transport.once('error', onerror); | ||
function onerror(err) { | ||
if (failed) return; | ||
// Any callback called by transport should be ignored since now | ||
failed = true; | ||
var error = new Error('probe error: ' + err); | ||
error.transport = transport.name; | ||
transport.close(); | ||
transport = null; | ||
debug('probe transport "%s" failed because of error: %s', name, err); | ||
self.emit('error', error); | ||
}; | ||
transport.open(); | ||
@@ -207,2 +233,3 @@ | ||
debug('socket closed prematurely - aborting probe'); | ||
failed = true; | ||
transport.close(); | ||
@@ -235,3 +262,5 @@ transport = null; | ||
if (this.upgrade && this.transport.pause) { | ||
// we check for `readyState` in case an `open` | ||
// listener alreay closed the socket | ||
if ('open' == this.readyState && this.upgrade && this.transport.pause) { | ||
debug('starting upgrade probes'); | ||
@@ -423,2 +452,4 @@ for (var i = 0, l = this.upgrades.length; i < l; i++) { | ||
debug('socket close with reason: "%s"', reason); | ||
clearTimeout(this.pingIntervalTimer); | ||
clearTimeout(this.pingTimeoutTimer); | ||
this.readyState = 'closed'; | ||
@@ -425,0 +456,0 @@ this.emit('close', reason, desc); |
@@ -5,3 +5,3 @@ { | ||
"main": "./lib/engine.io-client", | ||
"version": "0.3.9", | ||
"version": "0.3.10", | ||
"contributors": [ | ||
@@ -8,0 +8,0 @@ { "name": "Guillermo Rauch", "email": "rauchg@gmail.com" }, |
@@ -85,3 +85,3 @@ # Engine.IO SPEC | ||
send by the server. Client should answer with a pong package, containing the same data | ||
send by the server. Client should answer with a pong packets, containing the same data | ||
@@ -94,3 +94,3 @@ example | ||
send by the client to respond to ping packages. | ||
send by the client to respond to ping packets. | ||
@@ -114,3 +114,3 @@ #### 4 message | ||
Before engine.io switches a transport, it tests, if server and client can communicate over this transport. | ||
If this test succeed, the client sends an upgrade package which requests the server to flush its cache on | ||
If this test succeed, the client sends an upgrade packets which requests the server to flush its cache on | ||
the old transport and switch to the new transport. | ||
@@ -137,3 +137,3 @@ | ||
* length: length of the packet in __characters__ | ||
* packet: actual package as descriped above | ||
* packet: actual packets as descriped above | ||
@@ -140,0 +140,0 @@ The payload is used for transports which do not support framing, as the polling protocol for example. |
Sorry, the diff of this file is not supported yet
417584
13896