forked from socketio/socket.io-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:LearnBoost/Socket.IO
- Loading branch information
Showing
157 changed files
with
5,955 additions
and
2,648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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* | ||
|
||
|
@@ -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* | ||
|
||
|
@@ -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* | ||
|
||
|
@@ -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. | ||
|
@@ -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 <[email protected]> | ||
|
||
Arnout Kazemier <[email protected]> | ||
|
||
### License | ||
|
||
(The MIT License) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ | |
|
||
var fs = require('fs'), | ||
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', | ||
|
@@ -28,16 +31,16 @@ 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"; | ||
|
||
console.log('Reading files…'); | ||
|
||
files.forEach(function(file){ | ||
var path = __dirname + '/../lib/' + file; | ||
console.log (' + ' + path); | ||
console.log(' + ' + path); | ||
content += fs.readFileSync(path) + "\n"; | ||
}); | ||
|
||
|
@@ -46,4 +49,11 @@ console.log('Generating…'); | |
fs.write(fs.openSync(__dirname + '/../socket.io.js', 'w'), content, 0, 'utf8'); | ||
console.log(' + ' + __dirname + '/../socket.io.js'); | ||
|
||
console.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!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
.tmp*~ | ||
*.local.* | ||
.pinf-* |
Oops, something went wrong.