Compare commits

...

11 Commits
1.6.0 ... 1.7.2

Author SHA1 Message Date
Damien Arrachequesne
1f59e4526a [chore] Release 1.7.2 (#2783) 2016-12-11 02:04:21 +01:00
Damien Arrachequesne
0a7afa85ea [chore] Bump engine.io to version 1.8.2 (#2782) 2016-12-11 01:27:19 +01:00
Serhii Sol
1e31769062 [fix] Fixes socket.use error packet (#2772)
* fix(socket): Fixes socket.use error packet which drops nodejs due to nuances of Nodejs' EventEmitter

* fix(socket): Fixes missing error event on socket

* fix(socket): test fix, should listen for clientSocket instead of server socket

* minor update
2016-12-01 02:25:13 +01:00
Damien Arrachequesne
797c9a3498 [chore] Release 1.7.1 (#2768) 2016-11-28 00:06:18 +01:00
Damien Arrachequesne
4f93a0b429 [chore] Release 1.7.0 (#2767) 2016-11-27 08:27:39 +01:00
Damien Arrachequesne
3c98130f15 [chore] Update client location and serve minified file (#2766)
Following https://github.com/socketio/socket.io-client/pull/1025, the
output files are now generated in the dist directory.
2016-11-27 08:24:27 +01:00
Damien Arrachequesne
9c23308c6e [chore] Bump engine.io to version 1.8.1 (#2765) 2016-11-27 07:55:02 +01:00
Tal Beja
955e5e0d91 [feature] Add a local flag (#2628)
That new flag will prevent the adapter (redis) from publishing the emit to the pub/sub server.

When several instances of a server receive the same event from a third party (not from a client), each server instance broadcasts the event to all his clients. With the local flag, and the change in the redis adapter, each server instance send the event only to his client, so each client receive only one unique event.
2016-11-24 23:44:52 +01:00
Zhu Liang
0ef55b26d4 [feature] serve sourcemap for socket.io-client (#2482) 2016-11-24 23:39:43 +01:00
Robbie Ferguson
4d8e2d342c [docs] Fixed grammar issues in the README.md (#2159)
Added a few periods and commas which were missing. Pluralised the word
'parameter' where it was incorrectly specified to singular on line 281.
Very minor edit. No source code changed.
2016-11-23 15:05:15 +01:00
Jérémy Lal
d48f848bb4 [docs] Comment connected socket availability for adapters (#2081) 2016-11-23 15:00:07 +01:00
7 changed files with 87 additions and 23 deletions

View File

@@ -1,4 +1,23 @@
1.7.2 / 2016-12-11
===================
* [chore] Bump engine.io to version 1.8.2 (#2782)
* [fix] Fixes socket.use error packet (#2772)
1.7.1 / 2016-11-28
===================
1.7.0 / 2016-11-27
===================
* [docs] Comment connected socket availability for adapters (#2081)
* [docs] Fixed grammar issues in the README.md (#2159)
* [feature] serve sourcemap for socket.io-client (#2482)
* [feature] Add a `local` flag (#2628)
* [chore] Bump engine.io to version 1.8.1 (#2765)
* [chore] Update client location and serve minified file (#2766)
1.6.0 / 2016-11-20
==================

View File

@@ -147,7 +147,7 @@ server.listen(3000);
__Potential drawbacks__:
* in some situations, when it is not possible to determine `origin` it may have value of `*`
* As this function will be executed for every request, it is advised to make this function work as fast as possible
* If `socket.io` is used together with `Express`, the CORS headers will be affected only for `socket.io` requests. For Express can use [cors](https://github.com/expressjs/cors)
* If `socket.io` is used together with `Express`, the CORS headers will be affected only for `socket.io` requests. For Express can use [cors](https://github.com/expressjs/cors).
### Server#sockets:Namespace
@@ -183,7 +183,7 @@ server.listen(3000);
Initializes and retrieves the given `Namespace` by its pathname
identifier `nsp`.
If the namespace was already initialized it returns it right away.
If the namespace was already initialized it returns it immediately.
### Server#emit
@@ -285,7 +285,7 @@ server.listen(3000);
### Namespace#use(fn:Function):Namespace
Registers a middleware, which is a function that gets executed for
every incoming `Socket` and receives as parameter the socket and a
every incoming `Socket`, and receives as parameters the socket and a
function to optionally defer execution to the next registered
middleware.
@@ -448,7 +448,7 @@ These are reserved events (along with `connect`, `newListener` and `removeListen
### Client
The `Client` class represents an incoming transport (engine.io)
connection. A `Client` can be associated with many multiplexed `Socket`
connection. A `Client` can be associated with many multiplexed `Socket`s
that belong to different `Namespace`s.
### Client#conn

View File

@@ -26,6 +26,7 @@ module.exports = Server;
*/
var clientSource = undefined;
var clientSourceMap = undefined;
/**
* Server constructor.
@@ -97,7 +98,12 @@ Server.prototype.serveClient = function(v){
this._serveClient = v;
if (v && !clientSource) {
clientSource = read(require.resolve('socket.io-client/socket.io.js'), 'utf-8');
clientSource = read(require.resolve('socket.io-client/dist/socket.io.min.js'), 'utf-8');
try {
clientSourceMap = read(require.resolve('socket.io-client/dist/socket.io.js.map'), 'utf-8');
} catch(err) {
debug('could not load sourcemap file');
}
}
return this;
@@ -255,11 +261,14 @@ Server.prototype.attach = function(srv, opts){
Server.prototype.attachServe = function(srv){
debug('attaching client serving req handler');
var url = this._path + '/socket.io.js';
var urlMap = this._path + '/socket.io.js.map';
var evs = srv.listeners('request').slice(0);
var self = this;
srv.removeAllListeners('request');
srv.on('request', function(req, res) {
if (0 === req.url.indexOf(url)) {
if (0 === req.url.indexOf(urlMap)) {
self.serveMap(req, res);
} else if (0 === req.url.indexOf(url)) {
self.serve(req, res);
} else {
for (var i = 0; i < evs.length; i++) {
@@ -295,10 +304,41 @@ Server.prototype.serve = function(req, res){
debug('serve client source');
res.setHeader('Content-Type', 'application/javascript');
res.setHeader('ETag', expectedEtag);
res.setHeader('X-SourceMap', 'socket.io.js.map');
res.writeHead(200);
res.end(clientSource);
};
/**
* Handles a request serving `/socket.io.js.map`
*
* @param {http.Request} req
* @param {http.Response} res
* @api private
*/
Server.prototype.serveMap = function(req, res){
// Per the standard, ETags must be quoted:
// https://tools.ietf.org/html/rfc7232#section-2.3
var expectedEtag = '"' + clientVersion + '"';
var etag = req.headers['if-none-match'];
if (etag) {
if (expectedEtag == etag) {
debug('serve client 304');
res.writeHead(304);
res.end();
return;
}
}
debug('serve client sourcemap');
res.setHeader('Content-Type', 'application/json');
res.setHeader('ETag', expectedEtag);
res.writeHead(200);
res.end(clientSourceMap);
};
/**
* Binds socket.io to an engine.io instance.
*

View File

@@ -31,7 +31,8 @@ exports.events = [
exports.flags = [
'json',
'volatile'
'volatile',
'local'
];
/**

View File

@@ -283,6 +283,8 @@ Socket.prototype.leaveAll = function(){
/**
* Called by `Namespace` upon successful
* middleware execution (ie: authorization).
* Socket is added to namespace array before
* call to join, so adapters can access it.
*
* @api private
*/
@@ -496,7 +498,7 @@ Socket.prototype.dispatch = function(event){
this.run(event, function(err){
process.nextTick(function(){
if (err) {
return self.emit('error', err.data || err.message);
return self.error(err.data || err.message);
}
emit.apply(self, event);
});

View File

@@ -1,6 +1,6 @@
{
"name": "socket.io",
"version": "1.6.0",
"version": "1.7.2",
"description": "node.js realtime framework server",
"keywords": [
"realtime",
@@ -25,11 +25,11 @@
},
"dependencies": {
"debug": "2.3.3",
"engine.io": "1.8.0",
"engine.io": "1.8.2",
"has-binary": "0.1.7",
"object-assign": "4.1.0",
"socket.io-adapter": "0.5.0",
"socket.io-client": "1.6.0",
"socket.io-client": "1.7.2",
"socket.io-parser": "2.3.1"
},
"devDependencies": {

View File

@@ -2273,9 +2273,14 @@ describe('socket.io', function(){
var sio = io(srv);
srv.listen(function(){
var socket = client(srv, { multiplex: false });
var clientSocket = client(srv, { multiplex: false });
socket.emit('join', 'woot');
clientSocket.emit('join', 'woot');
clientSocket.on('error', function(err){
expect(err).to.be('Authentication error');
done();
});
sio.on('connection', function(socket){
socket.use(function(event, next){
@@ -2288,10 +2293,6 @@ describe('socket.io', function(){
socket.on('join', function(){
done(new Error('nope'));
});
socket.on('error', function(err){
expect(err).to.be('Authentication error');
done();
});
});
});
});
@@ -2301,9 +2302,14 @@ describe('socket.io', function(){
var sio = io(srv);
srv.listen(function(){
var socket = client(srv, { multiplex: false });
var clientSocket = client(srv, { multiplex: false });
socket.emit('join', 'woot');
clientSocket.emit('join', 'woot');
clientSocket.on('error', function(err){
expect(err).to.eql({ a: 'b', c: 3 });
done();
});
sio.on('connection', function(socket){
socket.use(function(event, next){
@@ -2315,10 +2321,6 @@ describe('socket.io', function(){
socket.on('join', function(){
done(new Error('nope'));
});
socket.on('error', function(err){
expect(err).to.eql({ a: 'b', c: 3 });
done();
});
});
});
});