Skip to content

Commit

Permalink
Update to socket.io v1.4.0 and socket.io-redis v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sgress454 committed Jan 6, 2016
1 parent 30e446e commit 95b2506
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
2 changes: 0 additions & 2 deletions lib/prepare-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ module.exports = function (app){
app.log.verbose('adapterConfig.subClient already specified!! (app running on port %d)', app.config.port);
}
adapterConfig.pubClient = adapterConfig.pubClient || redis.createClient(adapterConfig.port || 6379, adapterConfig.host || '127.0.0.1', _.extend({}, redisClientOpts, {
detect_buffers: true,
return_buffers: true
}));
adapterConfig.subClient = adapterConfig.subClient || redis.createClient(adapterConfig.port || 6379, adapterConfig.host || '127.0.0.1', _.extend({}, redisClientOpts,{
detect_buffers: true,

This comment has been minimized.

Copy link
@sgress454

sgress454 Jan 6, 2016

Author Member

With both detect_buffers and returns_buffers on, redis returns a warning, because return_buffers overrides detect_buffers (https://github.com/NodeRedis/node_redis#options-is-an-object-with-the-following-possible-properties)

return_buffers: true
}));

Expand Down
2 changes: 1 addition & 1 deletion lib/sails.sockets/broadcast-to-room.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = function (app){
}

// Otherwise broadcast to everyone in the room.
app.io.sockets.in(roomName).emit(eventName, data);
app.io.in(roomName).emit(eventName, data);

This comment has been minimized.

Copy link
@sgress454

sgress454 Jan 6, 2016

Author Member

Based on current socket.io docs.

};

Expand Down
2 changes: 1 addition & 1 deletion lib/sails.sockets/list-room-members.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = function (app){
// •-> https://github.com/Automattic/socket.io/issues/1908#issuecomment-66836641
// and •-> https://github.com/Automattic/socket.io/pull/1630#issuecomment-64389524

var socketIds = _.keys(app.io.nsps['/'].adapter.rooms[roomName]);
var socketIds = _.keys(app.io.nsps['/'].adapter.rooms[roomName].sockets);
if (returnSockets) {

This comment has been minimized.

Copy link
@sgress454

sgress454 Jan 6, 2016

Author Member

Necessary due to socketio/socket.io@b73d9be

var sockets = [];
_.each(socketIds, function (id) {
Expand Down
2 changes: 1 addition & 1 deletion lib/sails.sockets/list-rooms-joined-by-socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = function (app){
throw ERRORPACK.NO_SUCH_SOCKET('`sails.sockets.socketRooms()` cannot lookup room membership :: Cannot find socket with id=`%s`', id);
}

return foundSocket.rooms;
return _.keys(foundSocket.rooms);

This comment has been minimized.

Copy link
@sgress454

sgress454 Jan 6, 2016

Author Member

Necessary due to socketio/socket.io@b73d9be

// // manufacture an array of ids of room members
// var roomId = '';
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
"hook"
],
"dependencies": {
"socket.io": "^1.3.7",
"semver": "^4.3.4",
"lodash": "^2.4.1",
"machinepack-urls": "^3.1.1",
"socket.io-client": "^1.3.7"
"semver": "^4.3.4",
"socket.io": "1.4.0",
"socket.io-client": "1.4.0"
},
"devDependencies": {
"async": "^0.9.0",
"machinepack-fs": "^3.0.0",
"machinepack-http": "^2.1.2",
"mocha": "^2.2.4",
"sails": "0.11.0",
"sails": "~0.11.0",
"sails.io.js": "^0.11.5",
"socket.io-redis": "^0.1.4"
"socket.io-redis": "^1.0.0"
},
"scripts": {
"test": "node ./node_modules/mocha/bin/mocha test/** --timeout 5000"
Expand Down
2 changes: 1 addition & 1 deletion test/sails.sockets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('low-level socket methods:', function (){
// console.log('socket %s checking room membership...', sails.sockets.id(req.socket));
var result1 = sails.sockets.socketRooms(req.socket);
var result2 = sails.sockets.socketRooms(req);
assert.equal(result2, result1);
assert(_.isEqual(result2, result1));
return res.send(result1);

This comment has been minimized.

Copy link
@sgress454

sgress454 Jan 6, 2016

Author Member

Necessary due to socketio/socket.io@b73d9be

});
});
Expand Down
2 changes: 1 addition & 1 deletion test/with-redis.bus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('with redis -- bus', function (){
// New up five instances of Sails which share the config above
// and lift all of them (only difference is their port)
var apps = [];
var ports = [1600, 1601, 1602, 1603, 1604];
var ports = [1500, 1501, 1502, 1503, 1504];
before(function (done){

This comment has been minimized.

Copy link
@sgress454

sgress454 Jan 6, 2016

Author Member

There's some weirdness with the event emitters and the lifting/lowering of so many servers in the tests; keeping these ones on separate ports from the other redis tests seems to avoid conflict.

async.each(ports, function (port, next){
var app = Sails();
Expand Down

0 comments on commit 95b2506

Please sign in to comment.