Skip to content

Commit

Permalink
Merge remote branch 'learnboost/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbeardsley committed Apr 12, 2011
2 parents 1c1f26f + ce88922 commit 25eee98
Show file tree
Hide file tree
Showing 86 changed files with 1,087 additions and 2,879 deletions.
3 changes: 2 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

0.7.0 / 2011-??-??
0.6.17 / 2011-03-30
==================

* Fixed the 'possible EventEmitter memory leak detected' bug for the XHR transport
* Reconnection support added to chat example. [3rd-Eden]

0.6.16 / 2011-03-04
Expand Down
43 changes: 27 additions & 16 deletions lib/socket.io/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,33 +79,44 @@ Client.prototype._onMessage = function(data){
};

Client.prototype._onConnect = function(req, res){
var self = this;

var self = this
, attachConnection = !this.connection;

this.request = req;
this.response = res;
this.connection = req.connection;

this.connection.addListener('end', function(){
self._onClose();
if (self.connection)
self.connection.destroy();
});
if(!attachConnection) attachConnection = !attachConnection && this.connection.eventsAttached === undefined;
this.connection.eventsAttached = true;

if (attachConnection){
function destroyConnection(){
self._onClose();
self.connection && self.connection.destroy()
};
this.connection.addListener('end', destroyConnection);
this.connection.addListener('timeout', destroyConnection);
this.connection.addListener('error', destroyConnection);
}

if (req){
req.addListener('error', function(err){
function destroyRequest(){
req.destroy && req.destroy();
});
if (res) res.addListener('error', function(err){
res.destroy && res.destroy();
});
req.connection.addListener('error', function(err){
req.connection.destroy && req.connection.destroy();
});

};
req.addListener('error', destroyRequest);
req.addListener('timeout', destroyRequest);
if (res){
function destroyResponse(){
res.destroy && res.destroy();
}
res.addListener('error', destroyResponse);
res.addListener('timeout', destroyResponse);
}
if (this._disconnectTimeout) clearTimeout(this._disconnectTimeout);
}
};


Client.prototype._payload = function(){
var payload = [];

Expand Down
2 changes: 1 addition & 1 deletion lib/socket.io/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ exports.Listener = require('./listener');
* Version
*/

exports.version = '0.6.16';
exports.version = '0.6.17';
2 changes: 1 addition & 1 deletion lib/socket.io/transports/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ WebSocket.prototype._onConnect = function(req, socket){
}

var origin = this.request.headers.origin,
location = (origin && origin.substr(0, 5) == 'https' ? 'wss' : 'ws')
location = (this.request.socket.encrypted ? 'wss' : 'ws')
+ '://' + this.request.headers.host + this.request.url;

this.waitingForNonce = false;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "socket.io"
, "description": "The cross-browser WebSocket"
, "version": "0.6.16"
, "version": "0.6.17"
, "author": "Guillermo Rauch <[email protected]>"
, "contributors": [
{ "name": "Guillermo Rauch", "email": "[email protected]" }
Expand Down
102 changes: 78 additions & 24 deletions support/socket.io-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,25 @@ If you are serving you .swf from a other domain than socket.io.js you will need

The insecure version can be found [here](http://github.com/gimite/web-socket-js/blob/master/WebSocketMainInsecure.zip).

IMPORTANT! When checking out the git repo, make sure to include the submodules. One way to do it is:

git clone [repo] --recursive

Another, once cloned

git submodule update --init --recursive

### Documentation

#### io.Socket

new io.Socket(host, [options]);

Options:
##### Options:

- *secure*

false

Use secure connections

- *port*

Current port or 80

The port `socket.io` server is attached to (defaults to the document.location port)
The port `socket.io` server is attached to (defaults to the document.location port).

- *resource*

Expand All @@ -94,9 +92,9 @@ Options:

- *transports*

['websocket', 'flashsocket', 'htmlfile', 'xhr-multipart', 'xhr-polling']
['websocket', 'flashsocket', 'htmlfile', 'xhr-multipart', 'xhr-polling', 'jsonp-polling']

A list of the transports to attempt to utilize (in order of preference)
A list of the transports to attempt to utilize (in order of preference).

- *transportOptions*

Expand All @@ -109,11 +107,48 @@ Options:
An object containing (optional) options to pass to each transport.

Properties:
- *rememberTransport*

true

A boolean indicating if the utilized transport should be remembered in a cookie.

- *connectTimeout*

5000

The amount of miliseconds a transport has to create a connection before we consider it timed out.

- *tryTransportsOnConnectTimeout*

true

A boolean indicating if we should try other transports when the connectTimeout occurs.

- *reconnect*

true

A boolean indicating if we should automatically reconnect if a connection is disconnected.

- *reconnectionDelay*

500

The amount of milliseconds before we try to connect to the server again. We are using a exponential back off algorithm for the following reconnections, on each reconnect attempt this value will get multiplied (500 > 1000 > 2000 > 4000 > 8000).


- *maxReconnectionAttempts*

10

The amount of attempts should we make using the current transport to connect to the server? After this we will do one final attempt, and re-try with all enabled transport methods before we give up.

##### Properties:

- *options*

The passed in options combined with the defaults
The passed in options combined with the defaults.

- *connected*

Expand All @@ -122,46 +157,50 @@ Properties:
- *connecting*

Whether the socket is connecting or not.

- *reconnecting*

Whether we are reconnecting or not.

- *transport*

The transport instance.

Methods:
##### Methods:

- *connect*

Establishes a connection
Establishes a connection.

- *send(message)*

A string of data to send.

- *disconnect*

Closes the connection
Closes the connection.

- *on(event, λ)*

Adds a listener for the event *event*
Adds a listener for the event *event*.

- *removeEvent(event, λ)*

Removes the listener λ for the event *event*
Removes the listener λ for the event *event*.

Events:
##### Events:

- *connect*

Fired when the connection is established and the handshake successful
Fired when the connection is established and the handshake successful.

- *connecting(transport_type)*

Fired when a connection is attempted, passing the transport name
Fired when a connection is attempted, passing the transport name.

- *connect_failed*

Fired when the connection timeout occurs after the last connection attempt.
Fired when the connection timeout occurs after the last connection attempt.
This only fires if the `connectTimeout` option is set.
If the `tryTransportsOnConnectTimeout` option is set, this only fires once all
possible transports have been tried.
Expand All @@ -177,11 +216,26 @@ Events:
- *disconnect*

Fired when the connection is considered disconnected.

- *reconnect(transport_type,reconnectionAttempts)*

Fired when the connection has been re-established. This only fires if the `reconnect` option is set.

- *reconnecting(reconnectionDelay,reconnectionAttempts)*

Fired when a reconnection is attempted, passing the next delay for the next reconnection.

### Credits

- *reconnect_failed*

Fired when all reconnection attempts have failed and we where unsucessfull in reconnecting to the server.

### Contributors

Guillermo Rauch &lt;[email protected]&gt;

Arnout Kazemier &lt;[email protected]&gt;

### License

(The MIT License)
Expand Down
25 changes: 17 additions & 8 deletions support/socket.io-client/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
*/

var fs = require('fs'),
sys = require('sys'),
socket = require('../lib/io'),
jsp = require('../lib/vendor/uglifyjs/lib/parse-js'),
pro = require("../lib/vendor/uglifyjs/lib/process"),
ast,
files = [
'io.js',
'util.js',
Expand All @@ -29,22 +31,29 @@ var fs = require('fs'),
'transports/jsonp-polling.js',
'socket.js',
'vendor/web-socket-js/swfobject.js',
'vendor/web-socket-js/FABridge.js',
'vendor/web-socket-js/web_socket.js'
],
content = "/** Socket.IO "+ socket.io.version +" - Built with build.js */\n";
content = "/** Socket.IO "+ socket.io.version +" - Built with build.js */\n",
license = "/* Socket.IO.min "+ socket.io.version +" @author Guillermo Rauch <[email protected]>, @license The MIT license., @copyright Copyright (c) 2010 LearnBoost <[email protected]> */\n";

sys.log('Reading files…');
console.log('Reading files…');

files.forEach(function(file){
var path = __dirname + '/../lib/' + file;
sys.log (' + ' + path);
console.log(' + ' + path);
content += fs.readFileSync(path) + "\n";
});

sys.log('Generating…');
console.log('Generating…');

fs.write(fs.openSync(__dirname + '/../socket.io.js', 'w'), content, 0, 'utf8');
sys.log(' + ' + __dirname + '/../socket.io.js');
console.log(' + ' + __dirname + '/../socket.io.js');

sys.log('All done!');
console.log('Uglyfying…');
ast = jsp.parse(content);
ast = pro.ast_mangle(ast); // get a new AST with mangled names
ast = pro.ast_squeeze(ast);
fs.write(fs.openSync(__dirname + '/../socket.io.min.js', 'w'), license + pro.gen_code(ast), 0, 'utf8');
console.log(' + ' + __dirname + '/../socket.io.min.js');

console.log('All done!');
2 changes: 1 addition & 1 deletion support/socket.io-client/lib/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright Copyright (c) 2010 LearnBoost <[email protected]>
*/

this.io = {
var io = this.io = {
version: '0.6.2',

setPath: function(path){
Expand Down
Loading

0 comments on commit 25eee98

Please sign in to comment.