Compare commits

...

49 Commits
1.0.1 ... 1.0.6

Author SHA1 Message Date
Guillermo Rauch
d99e30fca7 Release 1.0.6 2014-06-19 14:57:50 -07:00
Guillermo Rauch
561dd6fd79 package: bump engine.io for utf8 fix (fixes #1622) 2014-06-19 14:51:37 -07:00
Guillermo Rauch
e9e2a91cea package: bump socket.io-client 2014-06-19 08:05:38 -07:00
Guillermo Rauch
8a3a111a7f Merge pull request #1635 from rase-/add/test
Test for duplicate events on manual reconnect
2014-06-18 15:54:23 -07:00
Tony Kovanen
bd87e4dc35 Bump socket.io-client to latest commit so that duplicate events test passes 2014-06-19 01:52:34 +03:00
Tony Kovanen
71c253e992 Added test for duplicate events after manual reconnects 2014-06-19 01:49:00 +03:00
Guillermo Rauch
a5cf4f57a0 Release 1.0.5 2014-06-17 18:14:44 -07:00
Guillermo Rauch
a079cbc7f9 client: fixes #1632 2014-06-17 18:07:30 -07:00
Guillermo Rauch
14a9fdb64f package: bump engine.io 2014-06-16 08:36:01 -07:00
Guillermo Rauch
6159df3937 fixed client 2014-06-13 13:04:50 -07:00
Guillermo Rauch
6f7bab5dfd Merge pull request #1578 from kevin-roark/add/emit-buffer-test
added the client emit-buffer test
2014-06-13 10:10:40 -07:00
Guillermo Rauch
7d2b44e176 index: fix typo [thanks @yanatan16] 2014-06-11 10:42:48 -07:00
Tony Kovanen
0b5fdf995a Merge pull request #1603 from nkzawa/patch-2
Add removeListener to blacklisted events
2014-06-08 14:40:25 +03:00
Naoyuki Kanezawa
a66bea5b33 add removeListener to blacklisted events 2014-06-08 20:34:50 +09:00
Guillermo Rauch
a1a88aaaaf Merge pull request #1600 from poldridge/master
Update index.js
2014-06-06 22:36:19 -07:00
poldridge
3f817c3a18 Update index.js
Added missing hasOwnProperty check. socket.io breaks without it when Object.prototype has been extended.
2014-06-06 22:08:58 -07:00
Guillermo Rauch
99bbd74d14 Merge pull request #1582 from kevin-roark/add/clearer-example-instructions
Add/clearer example instructions
2014-06-02 20:44:34 -07:00
Kevin Roark
398511ddee Merge branch 'upstream' into add/clearer-example-instructions 2014-06-02 20:28:42 -07:00
Kevin Roark
fdf7937815 clearer instructions to install chat example 2014-06-02 20:28:19 -07:00
Guillermo Rauch
475909e642 Release 1.0.4 2014-06-02 20:08:33 -07:00
Guillermo Rauch
95acec8b94 package: bump socket.io-client 2014-06-02 20:07:07 -07:00
Kevin Roark
5812ddf2b0 added the client emit-buffer test 2014-06-01 23:20:42 -07:00
Guillermo Rauch
1bbc3951bd Release 1.0.3 2014-05-31 18:34:50 -07:00
Guillermo Rauch
039eed2c2a package: bump socket.io-client 2014-05-31 09:53:25 -07:00
Guillermo Rauch
6de022b180 Merge pull request #1565 from kevin-roark/add/binary-ack
Add/binary ack
2014-05-31 09:50:19 -07:00
Guillermo Rauch
a06331d29f travis fix 2014-05-30 21:37:22 -07:00
Guillermo Rauch
e639685370 fix travis 2014-05-30 21:23:55 -07:00
Guillermo Rauch
1f2e681ce2 package: bump socket.io-parser for binary ack fix 2014-05-30 21:11:57 -07:00
Kevin Roark
397944fcbe big file tests 2014-05-30 20:40:44 -07:00
Kevin Roark
27dada65b9 distinction between ACK and BINARY_ACK 2014-05-30 18:42:23 -07:00
Guillermo Rauch
99f1ac9aae Merge pull request #1563 from rase-/fix/no-disconnect-fired-for-nsp
Fix namespace iterator in disconnect
2014-05-30 16:40:59 -07:00
Tony Kovanen
ee8d0fbae0 Fix namespace iterator in disconnect 2014-05-31 02:25:28 +03:00
Guillermo Rauch
8e08a6d419 Merge pull request #1562 from rase-/add/utf8-tests
Add test case for emitting multibyte chars
2014-05-30 15:48:34 -07:00
Tony Kovanen
318ae87f50 Add test case for emitting multibyte chars 2014-05-31 01:45:31 +03:00
Guillermo Rauch
2c1b61148d Merge branch 'master' of github.com:automattic/socket.io 2014-05-30 14:14:12 -07:00
Guillermo Rauch
507054c0a8 package: bump engine.io for utf8 binary fix 2014-05-30 14:09:54 -07:00
Tony Kovanen
dfceb006d7 Merge pull request #1554 from grant/master
Fix xss vulnerability in example chat app
2014-05-30 12:15:12 +03:00
Grant Timmerman
4d83456f74 Fix xss vulnerability in example chat app 2014-05-30 02:03:33 -07:00
Tony Kovanen
201aad83b1 Merge pull request #1540 from grant/master
Make chat example wrap long words (no overflow)
2014-05-30 12:02:15 +03:00
Grant Timmerman
72eb61d01f Make chat example wrap long words (no overflow) 2014-05-30 01:44:27 -07:00
Tony Kovanen
163a2a696e Merge pull request #1543 from mohnish/patch-1
Remove obsolete message from README file
2014-05-29 21:33:36 +03:00
Guillermo Rauch
199a479ebc Merge pull request #1545 from overra/patch-1
Use cleanInput() on incoming messages
2014-05-28 20:47:20 -07:00
Guillermo Rauch
d383ff9662 Merge pull request #1546 from hiddenmin/patch-1
Update Readme.md
2014-05-28 19:42:39 -07:00
Amin Cheloh
416b550189 Update Readme.md
socket.io-adapter link
2014-05-29 09:41:37 +07:00
Adam Snodgrass
536b338a01 Use cleanInput() on incoming messages
This prevents XSS if one were to send messages using socket.io from the console.
2014-05-28 20:35:24 -05:00
Mohnish Thallavajhula
a06ae10895 Remove obsolete message from README file 2014-05-28 17:10:50 -07:00
Guillermo Rauch
35a85084b1 Release 1.0.2 2014-05-28 13:24:59 -07:00
Guillermo Rauch
0c2b44a846 package: bump parser for windows fix 2014-05-28 13:23:51 -07:00
Guillermo Rauch
0f6ee2dbd9 travis 2014-05-28 12:56:10 -07:00
12 changed files with 174282 additions and 28 deletions

View File

@@ -1,4 +1,36 @@
1.0.6 / 2014-06-19
==================
* package: bump `socket.io-client`
1.0.5 / 2014-06-16
==================
* package: bump `engine.io` to fix jsonp `\n` bug and CORS warnings
* index: fix typo [yanatan16]
* add `removeListener` to blacklisted events
* examples: clearer instructions to install chat example
* index: fix namespace `connectBuffer` issue
1.0.4 / 2014-06-02
==================
* package: bump socket.io-client
1.0.3 / 2014-05-31
==================
* package: bump `socket.io-client`
* package: bump `socket.io-parser` for binary ACK fix
* package: bump `engine.io` for binary UTF8 fix
* example: fix XSS in chat example
1.0.2 / 2014-05-28
==================
* package: bump `socket.io-parser` for windows fix
1.0.1 / 2014-05-28
==================

View File

@@ -1,10 +1,7 @@
### This Readme corresponds to the upcoming 1.0 release. Please refer to http://socket.io for the current 0.9.x documentation.
<hr />
# socket.io
[![Build Status](https://secure.travis-ci.org/LearnBoost/socket.io.png)](http://travis-ci.org/LearnBoost/socket.io)
[![Build Status](https://secure.travis-ci.org/Automattic/socket.io.png)](http://travis-ci.org/Automattic/socket.io)
[![NPM version](https://badge.fury.io/js/socket.io.png)](http://badge.fury.io/js/socket.io)
## How to use
@@ -129,7 +126,7 @@ server.listen(3000);
Sets the adapter `v`. Defaults to an instance of the `Adapter` that
ships with socket.io which is memory based. See
[socket.io-adapter](https://github.com/learnboost/socket.io-adapter).
[socket.io-adapter](https://github.com/Automattic/socket.io-adapter).
If no arguments are supplied this method returns the current value.
@@ -288,7 +285,7 @@ server.listen(3000);
The mechanics of joining rooms are handled by the `Adapter`
that has been configured (see `Server#adapter` above), defaulting to
[socket.io-adapter](https://github.com/socket.io/socket.io-adapter).
[socket.io-adapter](https://github.com/Automattic/socket.io-adapter).
### Socket#leave(name:String[, fn:Function]):Socket
@@ -299,7 +296,7 @@ server.listen(3000);
The mechanics of leaving rooms are handled by the `Adapter`
that has been configured (see `Server#adapter` above), defaulting to
[socket.io-adapter](https://github.com/socket.io/socket.io-adapter).
[socket.io-adapter](https://github.com/Automattic/socket.io-adapter).
### Socket#to(room:String):Socket
### Socket#in(room:String):Socket

View File

@@ -6,6 +6,9 @@ A simple chat demo for socket.io
## How to use
```
$ cd socket.io
$ npm install
$ cd examples/chat
$ npm install
$ node .
```

View File

@@ -70,8 +70,8 @@ $(function() {
// Log a message
function log (message, options) {
var el = '<li class="log">' + message + '</li>';
addMessageElement(el, options);
var $el = $('<li>').addClass('log').text(message);
addMessageElement($el, options);
}
// Adds the visual chat message to the message list
@@ -84,16 +84,17 @@ $(function() {
$typingMessages.remove();
}
var colorStyle = 'style="color:' + getUsernameColor(data.username) + '"';
var usernameDiv = '<span class="username"' + colorStyle + '>' +
data.username + '</span>';
var messageBodyDiv = '<span class="messageBody">' +
data.message + '</span>';
var $usernameDiv = $('<span class="username"/>')
.text(data.username)
.css('color', getUsernameColor(data.username));
var $messageBodyDiv = $('<span class="messageBody">')
.text(data.message);
var typingClass = data.typing ? 'typing' : '';
var messageDiv = '<li class="message ' + typingClass + '">' +
usernameDiv + messageBodyDiv + '</li>';
var $messageDiv = $(messageDiv).data('username', data.username);
var $messageDiv = $('<li class="message"/>')
.data('username', data.username)
.addClass(typingClass)
.append($usernameDiv, $messageBodyDiv);
addMessageElement($messageDiv, options);
}
@@ -145,7 +146,7 @@ $(function() {
// Prevents input from having injected markup
function cleanInput (input) {
return $('<div/>').text(input).html() || input;
return $('<div/>').text(input).text();
}
// Updates the typing event

View File

@@ -25,6 +25,7 @@ html, body {
ul {
list-style: none;
word-wrap: break-word;
}
/* Pages */

View File

@@ -68,7 +68,7 @@ Client.prototype.connect = function(name){
self.sockets.push(socket);
self.nsps[nsp.name] = socket;
if ('/' == nsp.name) {
if ('/' == nsp.name && self.connectBuffer) {
self.connectBuffer.forEach(self.connect, self);
delete self.connectBuffer;
}
@@ -199,9 +199,10 @@ Client.prototype.onclose = function(reason){
this.destroy();
// `nsps` and `sockets` are cleaned up seamlessly
this.sockets.forEach(function(socket){
var socket;
while (socket = this.sockets.shift()) {
socket.onclose(reason);
});
}
this.decoder.destroy(); // clean up decoder
};

View File

@@ -159,7 +159,9 @@ Server.prototype.adapter = function(v){
if (!arguments.length) return this._adapter;
this._adapter = v;
for (var i in this.nsps) {
this.nsps[i].initAdapter();
if (this.nsps.hasOwnProperty(i)) {
this.nsps[i].initAdapter();
}
}
return this;
};

View File

@@ -25,7 +25,8 @@ exports.events = [
'error',
'connect',
'disconnect',
'newListener'
'newListener',
'removeListener'
];
/**
@@ -293,6 +294,10 @@ Socket.prototype.onpacket = function(packet){
this.onack(packet);
break;
case parser.BINARY_ACK:
this.onack(packet);
break;
case parser.DISCONNECT:
this.ondisconnect();
break;
@@ -336,9 +341,11 @@ Socket.prototype.ack = function(id){
if (sent) return;
var args = Array.prototype.slice.call(arguments);
debug('sending ack %j', args);
var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK;
self.packet({
id: id,
type: parser.ACK,
type: type,
data: args
});
};

View File

@@ -1,6 +1,6 @@
{
"name": "socket.io",
"version": "1.0.1",
"version": "1.0.6",
"description": "node.js realtime framework server",
"keywords": [
"realtime",
@@ -19,9 +19,9 @@
"test": "make test"
},
"dependencies": {
"engine.io": "1.2.1",
"socket.io-parser": "2.1.4",
"socket.io-client": "1.0.1",
"engine.io": "1.3.1",
"socket.io-parser": "2.2.0",
"socket.io-client": "1.0.6",
"socket.io-adapter": "0.2.0",
"has-binary-data": "0.1.1",
"debug": "0.7.4"

BIN
test/fixtures/big.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 MiB

174066
test/fixtures/big.json vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -395,10 +395,55 @@ describe('socket.io', function(){
}
});
});
it('should disconnect both default and custom namespace upon disconnect', function(done){
var srv = http();
var sio = io(srv);
srv.listen(function(){
var lolcats = client(srv, '/lolcats');
var total = 2;
var totald = 2;
var s;
sio.of('/', function(socket){
socket.on('disconnect', function(reason){
--totald || done();
});
--total || close();
});
sio.of('/lolcats', function(socket){
s = socket;
socket.on('disconnect', function(reason){
--totald || done();
});
--total || close();
});
function close(){
s.disconnect(true);
}
});
});
});
});
describe('socket', function(){
it('should not fire events more than once after manually reconnecting', function(done) {
var srv = http();
var sio = io(srv);
srv.listen(function(){
var clientSocket = client(srv, { reconnection: false });
clientSocket.on('connect', function init() {
clientSocket.removeListener('connect', init);
clientSocket.io.engine.close();
clientSocket.connect();
clientSocket.on('connect', function() {
done();
});
});
});
});
it('should receive events', function(done){
var srv = http();
var sio = io(srv);
@@ -446,6 +491,28 @@ describe('socket.io', function(){
});
});
it('should emit events with utf8 multibyte character', function(done) {
var srv = http();
var sio = io(srv);
srv.listen(function(){
var socket = client(srv);
var i = 0;
socket.on('hoot', function(a){
expect(a).to.be('utf8 — string');
i++;
if (3 == i) {
done();
}
});
sio.on('connection', function(s){
s.emit('hoot', 'utf8 — string');
s.emit('hoot', 'utf8 — string');
s.emit('hoot', 'utf8 — string');
});
});
});
it('should emit events with binary data', function(done){
var srv = http();
var sio = io(srv);
@@ -570,6 +637,30 @@ describe('socket.io', function(){
});
});
it('should receive all events emitted from namespaced client immediately and in order', function(done) {
var srv = http();
var sio = io(srv);
var total = 0;
srv.listen(function(){
sio.of('/chat', function(s){
s.on('hi', function(letter){
total++;
if (total == 2 && letter == 'b') {
done();
} else if (total == 1 && letter != 'a') {
throw new Error('events out of order');
}
});
});
var chat = client(srv, '/chat');
chat.emit('hi', 'a');
setTimeout(function() {
chat.emit('hi', 'b');
}, 50);
});
});
it('should emit events with callbacks', function(done){
var srv = http();
var sio = io(srv);
@@ -746,6 +837,59 @@ describe('socket.io', function(){
});
});
});
it('should handle very large json', function(done){
this.timeout();
var srv = http();
var sio = io(srv);
var received = 0;
srv.listen(function(){
var socket = client(srv);
socket.on('big', function(a){
expect(Buffer.isBuffer(a.json)).to.be(false);
if (++received == 3)
done();
else
socket.emit('big', a);
});
sio.on('connection', function(s){
fs.readFile(join(__dirname, 'fixtures', 'big.json'), function(err, data){
if (err) return done(err);
data = JSON.parse(data);
s.emit('big', {hello: 'friend', json: data});
});
s.on('big', function(a){
s.emit('big', a);
});
});
});
});
it('should handle very large binary data', function(done){
var srv = http();
var sio = io(srv);
var received = 0;
srv.listen(function(){
var socket = client(srv);
socket.on('big', function(a){
expect(Buffer.isBuffer(a.image)).to.be(true);
if (++received == 3)
done();
else
socket.emit('big', a);
});
sio.on('connection', function(s){
fs.readFile(join(__dirname, 'fixtures', 'big.jpg'), function(err, data){
if (err) return done(err);
s.emit('big', {hello: 'friend', image: data});
});
s.on('big', function(a){
expect(Buffer.isBuffer(a.image)).to.be(true);
s.emit('big', a);
});
});
});
});
});
describe('messaging many', function(){