mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-11 16:08:24 -05:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e6f58fe27 | ||
|
|
e3fb39da3d | ||
|
|
cc275813b5 | ||
|
|
9d57245d65 | ||
|
|
9a05b3597e | ||
|
|
41f38b60e8 | ||
|
|
a9bbc38919 | ||
|
|
e282ab0e63 | ||
|
|
546d5203d4 | ||
|
|
69941e602b | ||
|
|
7ac9c2e888 | ||
|
|
fa1f50d173 | ||
|
|
20ddd5f11a | ||
|
|
e1891fd615 | ||
|
|
4d66f78ca2 | ||
|
|
6db6db41a2 | ||
|
|
713baa40e1 | ||
|
|
7c196f5b32 | ||
|
|
bd360a15ef | ||
|
|
ae7f25332a | ||
|
|
63fc15d276 | ||
|
|
00b75759f1 |
14
History.md
14
History.md
@@ -1,4 +1,18 @@
|
||||
|
||||
0.8.3 / 2011-09-03
|
||||
==================
|
||||
|
||||
* Fixed `\n` parsing for non-JSON packets (fixes #479).
|
||||
* Fixed parsing of certain unicode characters (fixes #451).
|
||||
* Fixed transport message packet logging.
|
||||
* Fixed emission of `error` event resulting in an uncaught exception if unhandled (fixes #476).
|
||||
* Fixed; allow for falsy values as the configuration value of `log level` (fixes #491).
|
||||
* Fixed repository URI in `package.json`. Fixes #504.
|
||||
* Added text/plain content-type to handshake responses [einaros]
|
||||
* Improved single byte writes [einaros]
|
||||
* Updated socket.io-flashsocket default port from 843 to 10843 [3rd-Eden]
|
||||
* Updated client.
|
||||
|
||||
0.8.2 / 2011-08-29
|
||||
==================
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ function Manager (server, options) {
|
||||
, 'heartbeat interval': 20
|
||||
, 'polling duration': 20
|
||||
, 'flash policy server': true
|
||||
, 'flash policy port': 843
|
||||
, 'flash policy port': 10843
|
||||
, 'destroy upgrade': true
|
||||
, 'browser client': true
|
||||
, 'browser client minification': false
|
||||
@@ -141,7 +141,7 @@ Manager.prototype.__defineGetter__('log', function () {
|
||||
if (this.disabled('log')) return;
|
||||
|
||||
var logger = this.get('logger');
|
||||
logger.level = this.get('log level');
|
||||
logger.level = this.get('log level') || -1;
|
||||
|
||||
return logger;
|
||||
});
|
||||
@@ -775,7 +775,7 @@ Manager.prototype.handleHandshake = function (data, req, res) {
|
||||
res.writeHead(200, { 'Content-Type': 'application/javascript' });
|
||||
res.end('io.j[' + data.query.jsonp + '](new Error("' + message + '"));');
|
||||
} else {
|
||||
res.writeHead(status);
|
||||
res.writeHead(status, { 'Content-Type': 'text/plain' });
|
||||
res.end(message);
|
||||
}
|
||||
};
|
||||
@@ -808,7 +808,7 @@ Manager.prototype.handleHandshake = function (data, req, res) {
|
||||
hs = 'io.j[' + data.query.jsonp + '](' + JSON.stringify(hs) + ');';
|
||||
res.writeHead(200, { 'Content-Type': 'application/javascript' });
|
||||
} else {
|
||||
res.writeHead(200);
|
||||
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||
}
|
||||
|
||||
res.end(hs);
|
||||
|
||||
@@ -324,8 +324,9 @@ SocketNamespace.prototype.handlePacket = function (sessid, packet) {
|
||||
case 'event':
|
||||
var params = [packet.name].concat(packet.args);
|
||||
|
||||
if (dataAck)
|
||||
if (dataAck) {
|
||||
params.push(ack);
|
||||
}
|
||||
|
||||
socket.$emit.apply(socket, params);
|
||||
break;
|
||||
|
||||
@@ -138,7 +138,7 @@ exports.encodePayload = function (packets) {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
var regexp = /^([^:]+):([0-9]+)?(\+)?:([^:]+)?:?(.*)?$/;
|
||||
var regexp = /([^:]+):([0-9]+)?(\+)?:([^:]+)?:?([\s\S]*)?/;
|
||||
|
||||
exports.decodePacket = function (data) {
|
||||
var pieces = data.match(regexp);
|
||||
|
||||
@@ -15,7 +15,7 @@ var client = require('socket.io-client');
|
||||
* Version.
|
||||
*/
|
||||
|
||||
exports.version = '0.8.2';
|
||||
exports.version = '0.8.4';
|
||||
|
||||
/**
|
||||
* Supported protocol version.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
var parser = require('./parser')
|
||||
, util = require('./util')
|
||||
, EventEmitter = process.EventEmitter;
|
||||
, EventEmitter = process.EventEmitter
|
||||
|
||||
/**
|
||||
* Export the constructor.
|
||||
@@ -19,6 +19,12 @@ var parser = require('./parser')
|
||||
|
||||
exports = module.exports = Socket;
|
||||
|
||||
/**
|
||||
* Default error event listener to prevent uncaught exceptions.
|
||||
*/
|
||||
|
||||
var defaultError = function () {};
|
||||
|
||||
/**
|
||||
* Socket constructor.
|
||||
*
|
||||
@@ -39,6 +45,7 @@ function Socket (manager, id, nsp, readable) {
|
||||
this.setFlags();
|
||||
this.readable = readable;
|
||||
this.store = this.manager.store.client(this.id);
|
||||
this.on('error', defaultError);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -160,7 +167,7 @@ Socket.prototype.join = function (name, fn) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Joins a user to a room.
|
||||
* Un-joins a user from a room.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
@@ -56,7 +56,7 @@ HTTPTransport.prototype.handleRequest = function (req) {
|
||||
req.on('end', function () {
|
||||
res.writeHead(200, headers);
|
||||
res.end('1');
|
||||
|
||||
|
||||
self.onData(self.postEncoded ? qs.parse(buffer).d : buffer);
|
||||
});
|
||||
|
||||
@@ -83,9 +83,9 @@ HTTPTransport.prototype.handleRequest = function (req) {
|
||||
|
||||
HTTPTransport.prototype.onData = function (data) {
|
||||
var messages = parser.decodePayload(data);
|
||||
this.log.debug(this.name + ' received data packet', data);
|
||||
|
||||
for (var i = 0, l = messages.length; i < l; i++) {
|
||||
this.log.debug(this.name + ' received data packet', data);
|
||||
this.onMessage(messages[i]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -176,9 +176,9 @@ WebSocket.prototype.write = function (data) {
|
||||
var length = Buffer.byteLength(data)
|
||||
, buffer = new Buffer(2 + length);
|
||||
|
||||
buffer.write('\u0000', 'binary');
|
||||
buffer.write('\x00', 'binary');
|
||||
buffer.write(data, 1, 'utf8');
|
||||
buffer.write('\uffff', 1 + length, 'binary');
|
||||
buffer.write('\xff', 1 + length, 'binary');
|
||||
|
||||
try {
|
||||
if (this.socket.write(buffer)) {
|
||||
|
||||
@@ -139,9 +139,9 @@ WebSocket.prototype.write = function (data) {
|
||||
*/
|
||||
|
||||
WebSocket.prototype.frame = function (opcode, str) {
|
||||
var dataBuffer = new Buffer(str);
|
||||
var dataLength = dataBuffer.length;
|
||||
var startOffset = 2
|
||||
var dataBuffer = new Buffer(str)
|
||||
, dataLength = dataBuffer.length
|
||||
, startOffset = 2
|
||||
, secondByte = dataLength;
|
||||
if (dataLength > 65536) {
|
||||
startOffset = 10;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "socket.io"
|
||||
, "version": "0.8.2"
|
||||
, "version": "0.8.4"
|
||||
, "description": "Real-time apps made cross-browser & easy with a WebSocket-like API"
|
||||
, "homepage": "http://socket.io"
|
||||
, "keywords": ["websocket", "socket", "realtime", "socket.io", "comet", "ajax"]
|
||||
@@ -13,10 +13,10 @@
|
||||
]
|
||||
, "repository":{
|
||||
"type": "git"
|
||||
, "url": "https://github.com/LearnBoost/Socket.IO-node.git"
|
||||
, "url": "https://github.com/LearnBoost/socket.io.git"
|
||||
}
|
||||
, "dependencies": {
|
||||
"socket.io-client": "0.8.2"
|
||||
"socket.io-client": "0.8.4"
|
||||
, "policyfile": "0.0.4"
|
||||
, "redis": "0.6.6"
|
||||
}
|
||||
|
||||
@@ -343,6 +343,14 @@ module.exports = {
|
||||
parser.encodePacket({ type: 'message', data: '5', endpoint: '' })
|
||||
, parser.encodePacket({ type: 'message', data: '53d', endpoint: '' })
|
||||
]).should.eql('\ufffd5\ufffd3:::5\ufffd7\ufffd3:::53d')
|
||||
},
|
||||
|
||||
'test decoding newline': function () {
|
||||
parser.decodePacket('3:::\n').should.eql({
|
||||
type: 'message'
|
||||
, endpoint: ''
|
||||
, data: '\n'
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ module.exports = {
|
||||
var io = sio.listen(http.createServer())
|
||||
, port = ++ports;
|
||||
|
||||
io.get('flash policy port').should.eql(843);
|
||||
io.get('flash policy port').should.eql(10843);
|
||||
io.set('flash policy port', port);
|
||||
io.get('flash policy port').should.eql(port);
|
||||
|
||||
|
||||
@@ -950,6 +950,44 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
'test that emitting an error event doesnt throw': function (done) {
|
||||
var cl = client(++ports)
|
||||
, io = create(cl)
|
||||
|
||||
io.configure(function () {
|
||||
io.set('polling duration', .05);
|
||||
io.set('close timeout', .05);
|
||||
});
|
||||
|
||||
io.sockets.on('connection', function (socket) {
|
||||
socket.on('disconnect', function () {
|
||||
cl.end();
|
||||
io.server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
, parser.encodePacket({
|
||||
type: 'event'
|
||||
, name: 'error'
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.equal('1');
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'test emitting an event to the server with data': function (done) {
|
||||
var cl = client(++ports)
|
||||
, io = create(cl)
|
||||
|
||||
Reference in New Issue
Block a user