Skip to content

Commit

Permalink
update socket.io-client 0.9.1-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuke Hata committed Mar 8, 2012
1 parent 02f76dd commit b88576b
Show file tree
Hide file tree
Showing 17 changed files with 199 additions and 63 deletions.
41 changes: 41 additions & 0 deletions Resources/socket.io/History.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,45 @@

0.9.1-1 / 2012-03-02
====================

* Fixed active-x-obfuscator NPM dependency.

0.9.1 / 2012-03-02
==================

* Misc corrections.
* Added warning within Firefox about webworker test in test runner.
* Update ws dependency [einaros]
* Implemented client side heartbeat checks. [felixge]
* Improved Firewall support with ActiveX obfuscation. [felixge]
* Fixed error handling during connection process. [Outsideris]

0.9.0 / 2012-02-26
==================

* Added DS_Store to gitignore.
* Updated depedencies.
* Bumped uglify
* Tweaking code so it doesn't throw an exception when used inside a WebWorker in Firefox
* Do not rely on Array.prototype.indexOf as it breaks with pages that use the Prototype.js library.
* Windows support landed
* Use @einaros ws module instead of the old crap one
* Fix for broken closeTimeout and 'IE + xhr' goes into infinite loop on disconnection
* Disabled reconnection on error if reconnect option is set to false
* Set withCredentials to true before xhr to fix authentication
* Clears the timeout from reconnection attempt when there is a successful or failed reconnection.
This fixes the issue of setTimeout's carrying over from previous reconnection
and changing (skipping) values of self.reconnectionDelay in the newer reconnection.
* Removed decoding of parameters when chunking the query string.
This was used later on to construct the url to post to the socket.io server
for connection and if we're adding custom parameters of our own to this url
(for example for OAuth authentication) they were being sent decoded, which is wrong.

0.8.7 / 2011-11-05
==================

* Bumped client

0.8.6 / 2011-10-27
==================

Expand Down
5 changes: 4 additions & 1 deletion Resources/socket.io/bin/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

var fs = require('fs')
, socket = require('../lib/io')
, uglify = require('uglify-js');
, uglify = require('uglify-js')
, activeXObfuscator = require('active-x-obfuscator');

/**
* License headers.
Expand Down Expand Up @@ -182,6 +183,8 @@ var builder = module.exports = function () {
});
}

code = activeXObfuscator(code);

// Search for conditional code blocks that need to be removed as they
// where designed for a server side env. but only if we don't want to
// make this build node compatible.
Expand Down
85 changes: 57 additions & 28 deletions Resources/socket.io/dist/socket.io.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Resources/socket.io/dist/socket.io.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Resources/socket.io/lib/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @api public
*/

io.version = '0.8.7';
io.version = '0.9.1-1';

/**
* Protocol implemented.
Expand Down
44 changes: 35 additions & 9 deletions Resources/socket.io/lib/socket.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
Expand Down Expand Up @@ -149,6 +148,7 @@
var xhr = io.util.request();

xhr.open('GET', url, true);
xhr.withCredentials = true;
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
xhr.onreadystatechange = empty;
Expand Down Expand Up @@ -208,6 +208,8 @@
, self.options.transports
);

self.setHeartbeatTimeout();

function connect (transports){
if (self.transport) self.transport.clearTimeouts();

Expand Down Expand Up @@ -259,6 +261,22 @@
return this;
};

/**
* Clears and sets a new heartbeat timeout using the value given by the
* server during the handshake.
*
* @api private
*/

Socket.prototype.setHeartbeatTimeout = function () {
clearTimeout(this.heartbeatTimeoutTimer);

var self = this;
this.heartbeatTimeoutTimer = setTimeout(function () {
self.transport.onClose();
}, this.heartbeatTimeout);
};

/**
* Sends a message.
*
Expand Down Expand Up @@ -300,7 +318,7 @@
*/

Socket.prototype.disconnect = function () {
if (this.connected) {
if (this.connected || this.connecting) {
if (this.open) {
this.of('').packet({ type: 'disconnect' });
}
Expand Down Expand Up @@ -385,6 +403,7 @@

Socket.prototype.onClose = function () {
this.open = false;
clearTimeout(this.heartbeatTimeoutTimer);
};

/**
Expand All @@ -405,9 +424,11 @@

Socket.prototype.onError = function (err) {
if (err && err.advice) {
if (err.advice === 'reconnect' && this.connected) {
if (err.advice === 'reconnect' && (this.connected || this.connecting)) {
this.disconnect();
this.reconnect();
if (this.options.reconnect) {
this.reconnect();
}
}
}

Expand All @@ -421,19 +442,22 @@
*/

Socket.prototype.onDisconnect = function (reason) {
var wasConnected = this.connected;
var wasConnected = this.connected
, wasConnecting = this.connecting;

this.connected = false;
this.connecting = false;
this.open = false;

if (wasConnected) {
if (wasConnected || wasConnecting) {
this.transport.close();
this.transport.clearTimeouts();
this.publish('disconnect', reason);
if (wasConnected) {
this.publish('disconnect', reason);

if ('booted' != reason && this.options.reconnect && !this.reconnecting) {
this.reconnect();
if ('booted' != reason && this.options.reconnect && !this.reconnecting) {
this.reconnect();
}
}
}
};
Expand Down Expand Up @@ -464,6 +488,8 @@
self.publish('reconnect', self.transport.name, self.reconnectionAttempts);
}

clearTimeout(self.reconnectionTimer);

self.removeListener('connect_failed', maybeReconnect);
self.removeListener('connect', maybeReconnect);

Expand Down
4 changes: 3 additions & 1 deletion Resources/socket.io/lib/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// If the connection in currently open (or in a reopening state) reset the close
// timeout since we have just received data. This check is necessary so
// that we don't reset the timeout on an explicitly disconnected connection.
if (this.connected || this.connecting || this.reconnecting) {
if (this.socket.connected || this.socket.connecting || this.socket.reconnecting) {
this.setCloseTimeout();
}

Expand All @@ -70,6 +70,8 @@
*/

Transport.prototype.onPacket = function (packet) {
this.socket.setHeartbeatTimeout();

if (packet.type == 'heartbeat') {
return this.onHeartbeat();
}
Expand Down
3 changes: 1 addition & 2 deletions Resources/socket.io/lib/transports/htmlfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
Expand Down Expand Up @@ -136,7 +135,7 @@
*/

HTMLFile.check = function () {
if ('ActiveXObject' in window){
if (typeof window != "undefined" && 'ActiveXObject' in window){
try {
var a = new ActiveXObject('htmlfile');
return a && io.Transport.XHR.check();
Expand Down
2 changes: 1 addition & 1 deletion Resources/socket.io/lib/transports/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
, Socket

// if node
Socket = require('websocket-client').WebSocket;
Socket = require('ws');
// end node

if (!Socket) {
Expand Down
10 changes: 8 additions & 2 deletions Resources/socket.io/lib/transports/xhr-polling.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,20 @@

function onload () {
this.onload = empty;
this.onerror = empty;
self.onData(this.responseText);
self.get();
};

function onerror () {
self.onClose();
};

this.xhr = this.request();

if (global.XDomainRequest && this.xhr instanceof XDomainRequest) {
this.xhr.onload = this.xhr.onerror = onload;
this.xhr.onload = onload;
this.xhr.onerror = onerror;
} else {
this.xhr.onreadystatechange = stateChange;
}
Expand All @@ -113,7 +119,7 @@
io.Transport.XHR.prototype.onClose.call(this);

if (this.xhr) {
this.xhr.onreadystatechange = this.xhr.onload = empty;
this.xhr.onreadystatechange = this.xhr.onload = this.xhr.onerror = empty;
try {
this.xhr.abort();
} catch(e){}
Expand Down
8 changes: 2 additions & 6 deletions Resources/socket.io/lib/util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
Expand Down Expand Up @@ -106,7 +105,7 @@
for (; i < l; ++i) {
kv = params[i].split('=');
if (kv[0]) {
query[kv[0]] = decodeURIComponent(kv[1]);
query[kv[0]] = kv[1];
}
}

Expand Down Expand Up @@ -299,10 +298,7 @@
*/

util.indexOf = function (arr, o, i) {
if (Array.prototype.indexOf) {
return Array.prototype.indexOf.call(arr, o, i);
}


for (var j = arr.length, i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0;
i < j && arr[i] !== o; i++) {}

Expand Down
19 changes: 10 additions & 9 deletions Resources/socket.io/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "socket.io-client"
, "description": "Socket.IO client for the browser and node.js"
, "version": "0.8.7"
, "version": "0.9.1-1"
, "main" : "./lib/io.js"
, "browserify": "./dist/socket.io.js"
, "homepage": "http://socket.io"
Expand All @@ -18,17 +18,18 @@
, "url": "https://github.com/LearnBoost/socket.io-client.git"
}
, "dependencies": {
"uglify-js": "1.0.6"
, "websocket-client": "1.0.0"
"uglify-js": "1.2.5"
, "ws": "0.4.x"
, "xmlhttprequest": "1.2.2"
, "active-x-obfuscator": "0.0.1"
}
, "devDependencies": {
"expresso": "0.7.7"
, "express": "2.3.11"
, "jade": "0.12.1"
, "stylus": "0.13.3"
, "socket.io": "0.8.7"
, "socket.io-client": "0.8.7"
"expresso": "*"
, "express": "2.5.x"
, "jade": "*"
, "stylus": "*"
, "socket.io": "0.9.1-1"
, "socket.io-client": "0.9.1-1"
}
, "engines": { "node": ">= 0.4.0" }
}
1 change: 1 addition & 0 deletions Resources/socket.io/support/test-runner/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ app.get('/', function (req, res) {
res.render('index', {
layout: false
, testsPorts: testsPorts
, transport: transport
});
});

Expand Down
10 changes: 10 additions & 0 deletions Resources/socket.io/support/test-runner/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ html
title Socket.IO tests runner
body
h2 Socket.IO test runner

if ('websocket' == transport)
#warn-ff: p.warn
script
if ($.browser.mozilla)
$(function () {
$('#warn-ff p').html('<b>WARN:</b> WebSocket within WebWorker '
+ '<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=504553">'
+ 'expected to fail</a> on Firefox');
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body {
font-family: "Helvetica", "Helvetica Neue", sans-serif;
font-family: 'Helvetica', 'Helvetica Neue', sans-serif;
margin: 0;
color: #333;
font-size: 16px;
Expand Down Expand Up @@ -114,3 +114,14 @@ h2 a {
padding-left: 14px;
padding-bottom: 5px;
}
.warn {
background: #ffefc6;
padding: 5px;
text-align: center;
font-size: 15px;
text-shadow: 0 1px 0 #fff;
margin-bottom: 30px;
}
.warn b {
color: #ae0000;
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,13 @@ h2
line-height 5px
padding-left 14px
padding-bottom 5px

.warn
background: #FFEFC6
padding: 5px
text-align: center
font-size: 15px
text-shadow: 0 1px 0 white
margin-bottom: 30px
b
color: #AE0000

0 comments on commit b88576b

Please sign in to comment.