engine.io-client
Advanced tools
Comparing version 0.3.7 to 0.3.8
@@ -123,2 +123,3 @@ (function(){var global = this; | ||
if (window.localStorage) debug.enable(localStorage.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){ | ||
/** | ||
@@ -130,3 +131,3 @@ * Client version. | ||
exports.version = '0.3.7'; | ||
exports.version = '0.3.8'; | ||
@@ -572,5 +573,5 @@ /** | ||
opts = opts || {}; | ||
this.secure = null != opts.secure ? opts.secure : (global.location && 'https:' == global.location.protocol); | ||
this.host = opts.host || opts.hostname || 'localhost'; | ||
this.port = opts.port || (this.secure ? 443 : 80); | ||
this.secure = null != opts.secure ? opts.secure : (global.location && 'https:' == location.protocol); | ||
this.host = opts.host || opts.hostname || (global.location ? location.host : 'localhost'); | ||
this.port = opts.port || (global.location && location.port ? location.port : (this.secure ? 443 : 80)); | ||
this.query = opts.query || {}; | ||
@@ -591,2 +592,5 @@ this.query.uid = rnd(); | ||
this.open(); | ||
Socket.sockets.push(this); | ||
Socket.sockets.evs.emit('add', this); | ||
}; | ||
@@ -601,2 +605,9 @@ | ||
/** | ||
* Static EventEmitter. | ||
*/ | ||
Socket.sockets = []; | ||
Socket.sockets.evs = new EventEmitter; | ||
/** | ||
* Creates transport of the given type. | ||
@@ -781,2 +792,4 @@ * | ||
this.emit('packet', packet); | ||
// Socket is live - any packet counts | ||
@@ -907,2 +920,3 @@ this.emit('heartbeat'); | ||
var packet = { type: type, data: data }; | ||
this.emit('packetCreate', packet); | ||
this.writeBuffer.push(packet); | ||
@@ -923,2 +937,3 @@ this.flush(); | ||
this.transport.close(); | ||
this.transport.removeAllListeners(); | ||
} | ||
@@ -952,2 +967,3 @@ | ||
this.onclose && this.onclose.call(this); | ||
this.id = null; | ||
} | ||
@@ -1116,3 +1132,3 @@ }; | ||
var WS = require('./websocket') | ||
, util = require('../util') | ||
, util = require('../util'); | ||
@@ -1126,2 +1142,8 @@ /** | ||
/** | ||
* Obfuscated key for Blue Coat. | ||
*/ | ||
var xobject = global[['Active'].concat('Object').join('X')]; | ||
/** | ||
* FlashWS constructor. | ||
@@ -1169,3 +1191,3 @@ * | ||
// debug: [websocketjs %s] %s, type, str | ||
} | ||
}; | ||
}; | ||
@@ -1233,5 +1255,4 @@ | ||
FlashWS.prototype.ready = function (fn) { | ||
if (typeof WebSocket == 'undefined' | ||
|| !('__initialize' in WebSocket) || !swfobject | ||
) { | ||
if (typeof WebSocket == 'undefined' || | ||
!('__initialize' in WebSocket) || !swfobject) { | ||
return; | ||
@@ -1283,6 +1304,6 @@ } | ||
if (window.ActiveXObject) { | ||
if (xobject) { | ||
var control = null; | ||
try { | ||
control = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); | ||
control = new xobject('ShockwaveFlash.ShockwaveFlash'); | ||
} catch (e) { } | ||
@@ -1323,4 +1344,4 @@ if (control) { | ||
var el = document.createElement('script') | ||
, loaded = false | ||
var el = document.createElement('script'); | ||
var loaded = false; | ||
@@ -1647,3 +1668,3 @@ // debug: loading "%s", path | ||
, EventEmitter = require('../event-emitter') | ||
, util = require('../util') | ||
, util = require('../util'); | ||
@@ -1658,2 +1679,8 @@ /** | ||
/** | ||
* Obfuscated key for Blue Coat. | ||
*/ | ||
var xobject = global[['Active'].concat('Object').join('X')]; | ||
/** | ||
* Empty function | ||
@@ -1675,4 +1702,4 @@ */ | ||
if (global.location) { | ||
this.xd = opts.host != global.location.hostname | ||
|| global.location.port != opts.port; | ||
this.xd = opts.host != global.location.hostname || | ||
global.location.port != opts.port; | ||
} | ||
@@ -1723,4 +1750,4 @@ }; | ||
XHR.prototype.doWrite = function (data, fn) { | ||
var req = this.request({ method: 'POST', data: data }) | ||
, self = this | ||
var req = this.request({ method: 'POST', data: data }); | ||
var self = this; | ||
req.on('success', fn); | ||
@@ -1741,4 +1768,4 @@ req.on('error', function (err) { | ||
// debug: xhr poll | ||
var req = this.request() | ||
, self = this | ||
var req = this.request(); | ||
var self = this; | ||
req.on('data', function (data) { | ||
@@ -1782,4 +1809,4 @@ self.onData(data); | ||
Request.prototype.create = function () { | ||
var xhr = this.xhr = util.request(this.xd) | ||
, self = this | ||
var xhr = this.xhr = util.request(this.xd); | ||
var self = this; | ||
@@ -1837,3 +1864,3 @@ xhr.open(this.method, this.uri, this.async); | ||
if (global.ActiveXObject) { | ||
if (xobject) { | ||
this.index = Request.requestsCount++; | ||
@@ -1853,3 +1880,3 @@ Request.requests[this.index] = this; | ||
this.cleanup(); | ||
} | ||
}; | ||
@@ -1865,3 +1892,3 @@ /** | ||
this.onSuccess(); | ||
} | ||
}; | ||
@@ -1877,3 +1904,3 @@ /** | ||
this.cleanup(); | ||
} | ||
}; | ||
@@ -1897,3 +1924,3 @@ /** | ||
if (global.ActiveXObject) { | ||
if (xobject) { | ||
delete Request.requests[this.index]; | ||
@@ -1903,3 +1930,3 @@ } | ||
this.xhr = null; | ||
} | ||
}; | ||
@@ -1916,3 +1943,3 @@ /** | ||
if (global.ActiveXObject) { | ||
if (xobject) { | ||
Request.requestsCount = 0; | ||
@@ -1919,0 +1946,0 @@ Request.requests = {}; |
(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){ | ||
/** | ||
@@ -8,3 +9,3 @@ * Client version. | ||
exports.version = '0.3.7'; | ||
exports.version = '0.3.8'; | ||
@@ -450,5 +451,5 @@ /** | ||
opts = opts || {}; | ||
this.secure = null != opts.secure ? opts.secure : (global.location && 'https:' == global.location.protocol); | ||
this.host = opts.host || opts.hostname || 'localhost'; | ||
this.port = opts.port || (this.secure ? 443 : 80); | ||
this.secure = null != opts.secure ? opts.secure : (global.location && 'https:' == location.protocol); | ||
this.host = opts.host || opts.hostname || (global.location ? location.host : 'localhost'); | ||
this.port = opts.port || (global.location && location.port ? location.port : (this.secure ? 443 : 80)); | ||
this.query = opts.query || {}; | ||
@@ -469,2 +470,5 @@ this.query.uid = rnd(); | ||
this.open(); | ||
Socket.sockets.push(this); | ||
Socket.sockets.evs.emit('add', this); | ||
}; | ||
@@ -479,2 +483,9 @@ | ||
/** | ||
* Static EventEmitter. | ||
*/ | ||
Socket.sockets = []; | ||
Socket.sockets.evs = new EventEmitter; | ||
/** | ||
* Creates transport of the given type. | ||
@@ -659,2 +670,4 @@ * | ||
this.emit('packet', packet); | ||
// Socket is live - any packet counts | ||
@@ -785,2 +798,3 @@ this.emit('heartbeat'); | ||
var packet = { type: type, data: data }; | ||
this.emit('packetCreate', packet); | ||
this.writeBuffer.push(packet); | ||
@@ -801,2 +815,3 @@ this.flush(); | ||
this.transport.close(); | ||
this.transport.removeAllListeners(); | ||
} | ||
@@ -830,2 +845,3 @@ | ||
this.onclose && this.onclose.call(this); | ||
this.id = null; | ||
} | ||
@@ -994,3 +1010,3 @@ }; | ||
var WS = require('./websocket') | ||
, util = require('../util') | ||
, util = require('../util'); | ||
@@ -1004,2 +1020,8 @@ /** | ||
/** | ||
* Obfuscated key for Blue Coat. | ||
*/ | ||
var xobject = global[['Active'].concat('Object').join('X')]; | ||
/** | ||
* FlashWS constructor. | ||
@@ -1047,3 +1069,3 @@ * | ||
// debug: [websocketjs %s] %s, type, str | ||
} | ||
}; | ||
}; | ||
@@ -1111,5 +1133,4 @@ | ||
FlashWS.prototype.ready = function (fn) { | ||
if (typeof WebSocket == 'undefined' | ||
|| !('__initialize' in WebSocket) || !swfobject | ||
) { | ||
if (typeof WebSocket == 'undefined' || | ||
!('__initialize' in WebSocket) || !swfobject) { | ||
return; | ||
@@ -1161,6 +1182,6 @@ } | ||
if (window.ActiveXObject) { | ||
if (xobject) { | ||
var control = null; | ||
try { | ||
control = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); | ||
control = new xobject('ShockwaveFlash.ShockwaveFlash'); | ||
} catch (e) { } | ||
@@ -1201,4 +1222,4 @@ if (control) { | ||
var el = document.createElement('script') | ||
, loaded = false | ||
var el = document.createElement('script'); | ||
var loaded = false; | ||
@@ -1525,3 +1546,3 @@ // debug: loading "%s", path | ||
, EventEmitter = require('../event-emitter') | ||
, util = require('../util') | ||
, util = require('../util'); | ||
@@ -1536,2 +1557,8 @@ /** | ||
/** | ||
* Obfuscated key for Blue Coat. | ||
*/ | ||
var xobject = global[['Active'].concat('Object').join('X')]; | ||
/** | ||
* Empty function | ||
@@ -1553,4 +1580,4 @@ */ | ||
if (global.location) { | ||
this.xd = opts.host != global.location.hostname | ||
|| global.location.port != opts.port; | ||
this.xd = opts.host != global.location.hostname || | ||
global.location.port != opts.port; | ||
} | ||
@@ -1601,4 +1628,4 @@ }; | ||
XHR.prototype.doWrite = function (data, fn) { | ||
var req = this.request({ method: 'POST', data: data }) | ||
, self = this | ||
var req = this.request({ method: 'POST', data: data }); | ||
var self = this; | ||
req.on('success', fn); | ||
@@ -1619,4 +1646,4 @@ req.on('error', function (err) { | ||
// debug: xhr poll | ||
var req = this.request() | ||
, self = this | ||
var req = this.request(); | ||
var self = this; | ||
req.on('data', function (data) { | ||
@@ -1660,4 +1687,4 @@ self.onData(data); | ||
Request.prototype.create = function () { | ||
var xhr = this.xhr = util.request(this.xd) | ||
, self = this | ||
var xhr = this.xhr = util.request(this.xd); | ||
var self = this; | ||
@@ -1715,3 +1742,3 @@ xhr.open(this.method, this.uri, this.async); | ||
if (global.ActiveXObject) { | ||
if (xobject) { | ||
this.index = Request.requestsCount++; | ||
@@ -1731,3 +1758,3 @@ Request.requests[this.index] = this; | ||
this.cleanup(); | ||
} | ||
}; | ||
@@ -1743,3 +1770,3 @@ /** | ||
this.onSuccess(); | ||
} | ||
}; | ||
@@ -1755,3 +1782,3 @@ /** | ||
this.cleanup(); | ||
} | ||
}; | ||
@@ -1775,3 +1802,3 @@ /** | ||
if (global.ActiveXObject) { | ||
if (xobject) { | ||
delete Request.requests[this.index]; | ||
@@ -1781,3 +1808,3 @@ } | ||
this.xhr = null; | ||
} | ||
}; | ||
@@ -1794,3 +1821,3 @@ /** | ||
if (global.ActiveXObject) { | ||
if (xobject) { | ||
Request.requestsCount = 0; | ||
@@ -1797,0 +1824,0 @@ Request.requests = {}; |
0.3.8 / 2012-10-23 | ||
================== | ||
* socket: introduce introspection hooks | ||
* socket: introduced `host` and `port` `location` defaults | ||
* flashsocket: obfuscate activex (fixes #31) | ||
* README: documented reconnect (closes #45) | ||
* socket: unset `id` upon close | ||
* socket: clear transport listeners upon force close | ||
0.3.7 / 2012-10-21 | ||
@@ -3,0 +13,0 @@ ================== |
@@ -0,1 +1,2 @@ | ||
/** | ||
@@ -7,3 +8,3 @@ * Client version. | ||
exports.version = '0.3.7'; | ||
exports.version = '0.3.8'; | ||
@@ -10,0 +11,0 @@ /** |
@@ -33,5 +33,5 @@ /** | ||
opts = opts || {}; | ||
this.secure = null != opts.secure ? opts.secure : (global.location && 'https:' == global.location.protocol); | ||
this.host = opts.host || opts.hostname || 'localhost'; | ||
this.port = opts.port || (this.secure ? 443 : 80); | ||
this.secure = null != opts.secure ? opts.secure : (global.location && 'https:' == location.protocol); | ||
this.host = opts.host || opts.hostname || (global.location ? location.host : 'localhost'); | ||
this.port = opts.port || (global.location && location.port ? location.port : (this.secure ? 443 : 80)); | ||
this.query = opts.query || {}; | ||
@@ -52,2 +52,5 @@ this.query.uid = rnd(); | ||
this.open(); | ||
Socket.sockets.push(this); | ||
Socket.sockets.evs.emit('add', this); | ||
}; | ||
@@ -62,2 +65,9 @@ | ||
/** | ||
* Static EventEmitter. | ||
*/ | ||
Socket.sockets = []; | ||
Socket.sockets.evs = new EventEmitter; | ||
/** | ||
* Creates transport of the given type. | ||
@@ -242,2 +252,4 @@ * | ||
this.emit('packet', packet); | ||
// Socket is live - any packet counts | ||
@@ -368,2 +380,3 @@ this.emit('heartbeat'); | ||
var packet = { type: type, data: data }; | ||
this.emit('packetCreate', packet); | ||
this.writeBuffer.push(packet); | ||
@@ -384,2 +397,3 @@ this.flush(); | ||
this.transport.close(); | ||
this.transport.removeAllListeners(); | ||
} | ||
@@ -413,2 +427,3 @@ | ||
this.onclose && this.onclose.call(this); | ||
this.id = null; | ||
} | ||
@@ -415,0 +430,0 @@ }; |
@@ -7,3 +7,3 @@ | ||
var WS = require('./websocket') | ||
, util = require('../util') | ||
, util = require('../util'); | ||
@@ -17,2 +17,8 @@ /** | ||
/** | ||
* Obfuscated key for Blue Coat. | ||
*/ | ||
var xobject = global[['Active'].concat('Object').join('X')]; | ||
/** | ||
* FlashWS constructor. | ||
@@ -60,3 +66,3 @@ * | ||
// debug: [websocketjs %s] %s, type, str | ||
} | ||
}; | ||
}; | ||
@@ -124,5 +130,4 @@ | ||
FlashWS.prototype.ready = function (fn) { | ||
if (typeof WebSocket == 'undefined' | ||
|| !('__initialize' in WebSocket) || !swfobject | ||
) { | ||
if (typeof WebSocket == 'undefined' || | ||
!('__initialize' in WebSocket) || !swfobject) { | ||
return; | ||
@@ -174,6 +179,6 @@ } | ||
if (window.ActiveXObject) { | ||
if (xobject) { | ||
var control = null; | ||
try { | ||
control = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); | ||
control = new xobject('ShockwaveFlash.ShockwaveFlash'); | ||
} catch (e) { } | ||
@@ -214,4 +219,4 @@ if (control) { | ||
var el = document.createElement('script') | ||
, loaded = false | ||
var el = document.createElement('script'); | ||
var loaded = false; | ||
@@ -218,0 +223,0 @@ // debug: loading "%s", path |
@@ -7,3 +7,3 @@ /** | ||
, EventEmitter = require('../event-emitter') | ||
, util = require('../util') | ||
, util = require('../util'); | ||
@@ -18,2 +18,8 @@ /** | ||
/** | ||
* Obfuscated key for Blue Coat. | ||
*/ | ||
var xobject = global[['Active'].concat('Object').join('X')]; | ||
/** | ||
* Empty function | ||
@@ -35,4 +41,4 @@ */ | ||
if (global.location) { | ||
this.xd = opts.host != global.location.hostname | ||
|| global.location.port != opts.port; | ||
this.xd = opts.host != global.location.hostname || | ||
global.location.port != opts.port; | ||
} | ||
@@ -83,4 +89,4 @@ }; | ||
XHR.prototype.doWrite = function (data, fn) { | ||
var req = this.request({ method: 'POST', data: data }) | ||
, self = this | ||
var req = this.request({ method: 'POST', data: data }); | ||
var self = this; | ||
req.on('success', fn); | ||
@@ -101,4 +107,4 @@ req.on('error', function (err) { | ||
// debug: xhr poll | ||
var req = this.request() | ||
, self = this | ||
var req = this.request(); | ||
var self = this; | ||
req.on('data', function (data) { | ||
@@ -142,4 +148,4 @@ self.onData(data); | ||
Request.prototype.create = function () { | ||
var xhr = this.xhr = util.request(this.xd) | ||
, self = this | ||
var xhr = this.xhr = util.request(this.xd); | ||
var self = this; | ||
@@ -197,3 +203,3 @@ xhr.open(this.method, this.uri, this.async); | ||
if (global.ActiveXObject) { | ||
if (xobject) { | ||
this.index = Request.requestsCount++; | ||
@@ -213,3 +219,3 @@ Request.requests[this.index] = this; | ||
this.cleanup(); | ||
} | ||
}; | ||
@@ -225,3 +231,3 @@ /** | ||
this.onSuccess(); | ||
} | ||
}; | ||
@@ -237,3 +243,3 @@ /** | ||
this.cleanup(); | ||
} | ||
}; | ||
@@ -257,3 +263,3 @@ /** | ||
if (global.ActiveXObject) { | ||
if (xobject) { | ||
delete Request.requests[this.index]; | ||
@@ -263,3 +269,3 @@ } | ||
this.xhr = null; | ||
} | ||
}; | ||
@@ -276,3 +282,3 @@ /** | ||
if (global.ActiveXObject) { | ||
if (xobject) { | ||
Request.requestsCount = 0; | ||
@@ -279,0 +285,0 @@ Request.requests = {}; |
@@ -5,3 +5,3 @@ { | ||
"main": "./lib/engine.io-client", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"contributors": [ | ||
@@ -8,0 +8,0 @@ { "name": "Guillermo Rauch", "email": "rauchg@gmail.com" }, |
@@ -123,2 +123,7 @@ # Engine.IO client | ||
## Reconnecting | ||
A `Socket` instance can be reused. After closing (either by calling | ||
`Socket#close()` or network close), you can summon `open` again. | ||
## Flash transport | ||
@@ -125,0 +130,0 @@ |
414742
13824
186