mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-11 07:58:13 -05:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ca0606670 | ||
|
|
f6036007fc | ||
|
|
aa027ab571 | ||
|
|
b4f24c6995 | ||
|
|
3a53c63778 | ||
|
|
d8e3ccc637 | ||
|
|
cef5fb3574 | ||
|
|
cfbae2ac15 | ||
|
|
1072add73f | ||
|
|
648b1d0792 | ||
|
|
63624e5996 | ||
|
|
1ee5285136 | ||
|
|
5308452b8a | ||
|
|
2ee09436ce | ||
|
|
d2ecaff462 | ||
|
|
023566e03b | ||
|
|
c306a3c303 | ||
|
|
d648fc5a72 |
21
History.md
21
History.md
@@ -1,4 +1,25 @@
|
||||
|
||||
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
|
||||
===================
|
||||
|
||||
* Fixed cross domain xhr-polling in Safari [tifroz]
|
||||
|
||||
0.6.15 / 2011-02-23
|
||||
===================
|
||||
|
||||
* Fixed memory leak in WebSocket transport [belorion]
|
||||
|
||||
0.6.14 / 2011-02-18
|
||||
===================
|
||||
|
||||
* Fixed logging scope issue [shripad]
|
||||
|
||||
0.6.13 / 2011-02-18
|
||||
===================
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
var el = document.createElement('p');
|
||||
if ('announcement' in obj) el.innerHTML = '<em>' + esc(obj.announcement) + '</em>';
|
||||
else if ('message' in obj) el.innerHTML = '<b>' + esc(obj.message[0]) + ':</b> ' + esc(obj.message[1]);
|
||||
|
||||
if( obj.message && window.console && console.log ) console.log(obj.message[0], obj.message[1]);
|
||||
document.getElementById('chat').appendChild(el);
|
||||
document.getElementById('chat').scrollTop = 1000000;
|
||||
}
|
||||
@@ -38,11 +40,17 @@
|
||||
for (var i in obj.buffer) message(obj.buffer[i]);
|
||||
} else message(obj);
|
||||
});
|
||||
|
||||
socket.on('connect', function(){ message({ message: ['System', 'Connected']})});
|
||||
socket.on('disconnect', function(){ message({ message: ['System', 'Disconnected']})});
|
||||
socket.on('reconnect', function(){ message({ message: ['System', 'Reconnected to server']})});
|
||||
socket.on('reconnecting', function( nextRetry ){ message({ message: ['System', 'Attempting to re-connect to the server, next attempt in ' + nextRetry + 'ms']})});
|
||||
socket.on('reconnect_failed', function(){ message({ message: ['System', 'Reconnected to server FAILED.']})});
|
||||
</script>
|
||||
|
||||
<h1>Sample chat client</h1>
|
||||
<div id="chat"><p>Connecting...</p></div>
|
||||
<form id="form" onsubmit="send(); return false">
|
||||
<form id="form" onSubmit="send(); return false">
|
||||
<input type="text" autocomplete="off" id="text"><input type="submit" value="Send">
|
||||
</form>
|
||||
|
||||
|
||||
@@ -61,33 +61,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 = [];
|
||||
|
||||
|
||||
@@ -23,4 +23,4 @@ exports.Listener = require('./listener');
|
||||
* Version
|
||||
*/
|
||||
|
||||
exports.version = '0.6.13';
|
||||
exports.version = '0.6.17';
|
||||
|
||||
@@ -33,7 +33,7 @@ HTMLFile.prototype._onConnect = function(req, res){
|
||||
var msg = qs.parse(body);
|
||||
self._onMessage(msg.data);
|
||||
} catch(e){
|
||||
this.listener.options.log('htmlfile message handler error - ' + e.stack);
|
||||
self.listener.options.log('htmlfile message handler error - ' + e.stack);
|
||||
}
|
||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||
res.write('ok');
|
||||
|
||||
@@ -99,18 +99,16 @@ WebSocket.prototype._onConnect = function(req, socket){
|
||||
this.buffer = "";
|
||||
|
||||
this.connection.addListener('data', function(data){
|
||||
self.buffer += data;
|
||||
if (self.waitingForNonce) {
|
||||
self.buffer += data;
|
||||
|
||||
if (self.buffer.length < 8) { return; }
|
||||
// Restore the connection to utf8 encoding after receiving the nonce
|
||||
self.connection.setEncoding('utf8');
|
||||
self.waitingForNonce = false;
|
||||
// Stuff the nonce into the location where it's expected to be
|
||||
self.upgradeHead = self.buffer.substr(0,8);
|
||||
self.buffer = self.buffer.substr(8);
|
||||
if (self.buffer.length > 0) {
|
||||
self.parser.add(self.buffer);
|
||||
}
|
||||
self.buffer = '';
|
||||
if (self._proveReception(self._headers)) { self._payload(); }
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ Multipart.prototype._onConnect = function(req, res){
|
||||
var msg = qs.parse(body);
|
||||
self._onMessage(msg.data);
|
||||
} catch(e){
|
||||
this.listener.options.log('xhr-multipart message handler error - ' + e.stack);
|
||||
self.listener.options.log('xhr-multipart message handler error - ' + e.stack);
|
||||
}
|
||||
res.writeHead(200, headers);
|
||||
res.write('ok');
|
||||
|
||||
@@ -49,7 +49,7 @@ Polling.prototype._onConnect = function(req, res){
|
||||
var msg = qs.parse(body);
|
||||
self._onMessage(msg.data);
|
||||
} catch(e){
|
||||
this.listener.options.log('xhr-polling message handler error - ' + e.stack);
|
||||
self.listener.options.log('xhr-polling message handler error - ' + e.stack);
|
||||
}
|
||||
res.writeHead(200, headers);
|
||||
res.write('ok');
|
||||
@@ -69,7 +69,7 @@ Polling.prototype._write = function(message){
|
||||
var headers = {'Content-Type': 'text/plain; charset=UTF-8', 'Content-Length': Buffer.byteLength(message)};
|
||||
// https://developer.mozilla.org/En/HTTP_Access_Control
|
||||
if (this.request.headers.origin && this._verifyOrigin(this.request.headers.origin)){
|
||||
headers['Access-Control-Allow-Origin'] = this.request.headers.origin;
|
||||
headers['Access-Control-Allow-Origin'] = (this.request.headers.origin === 'null' ? '*' : this.request.headers.origin);
|
||||
if (this.request.headers.cookie) headers['Access-Control-Allow-Credentials'] = 'true';
|
||||
}
|
||||
this.response.writeHead(200, headers);
|
||||
|
||||
34
package.json
34
package.json
@@ -1,17 +1,21 @@
|
||||
{ "name" : "socket.io"
|
||||
, "description" : "The cross-browser WebSocket"
|
||||
, "version" : "0.6.13"
|
||||
, "author" : "LearnBoost"
|
||||
, "licenses" :
|
||||
[ { "type" : "MIT"
|
||||
, "url" : "http://github.com/learnboost/Socket.IO-node/raw/master/README.md"
|
||||
{
|
||||
"name": "socket.io"
|
||||
, "description": "The cross-browser WebSocket"
|
||||
, "version": "0.6.17"
|
||||
, "author": "Guillermo Rauch <guillermo@learnboost.com>"
|
||||
, "contributors": [
|
||||
{ "name": "Guillermo Rauch", "email": "rauchg@gmail.com" }
|
||||
, { "name": "Arnout Kazemier", "email": "info@3rd-eden.com" }
|
||||
]
|
||||
, "licenses": [{
|
||||
"type": "MIT"
|
||||
, "url": "http://github.com/learnboost/Socket.IO-node/raw/master/README.md"
|
||||
}]
|
||||
, "repository": {
|
||||
"type": "git"
|
||||
, "url": "http://github.com/learnboost/Socket.IO-node.git"
|
||||
}
|
||||
]
|
||||
, "repository" :
|
||||
{ "type" : "git"
|
||||
, "url" : "http://github.com/learnboost/Socket.IO-node.git"
|
||||
}
|
||||
, "engine" : [ "node >=0.1.102" ]
|
||||
, "main" : "./index"
|
||||
, "scripts" : { "test" : "make test" }
|
||||
, "engine": [ "node >=0.1.102" ]
|
||||
, "main": "./index"
|
||||
, "scripts": { "test" : "make test" }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user