Skip to content

Commit 0ab9b1b

Browse files
committed
Merge pull request #341 from kingcody/feature/upgrade-socket.io
feat(app-socket.io) upgrade socket.io and code to use v1.0.6
2 parents 4ef9f57 + 138d0e5 commit 0ab9b1b

File tree

4 files changed

+13
-30
lines changed

4 files changed

+13
-30
lines changed

Diff for: app/templates/_package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"passport-google-oauth": "latest",<% } %>
2626
"composable-middleware": "^0.3.0",
2727
"connect-mongo": "^0.4.1"<% if(filters.socketio) { %>,
28-
"socket.io": "~0.9.16",
28+
"socket.io": "~1.0.6",
2929
"socketio-jwt": "^2.0.2"<% } %>
3030
},
3131
"devDependencies": {

Diff for: app/templates/client/components/socket(socketio)/socket.service.js

+3-20
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,13 @@
33

44
angular.module('<%= scriptAppName %>')
55
.factory('socket', function(socketFactory) {
6-
var retryInterval = 5000;
7-
var retryTimer;
86

9-
clearInterval(retryTimer);
10-
11-
var ioSocket = io.connect('', {
12-
'force new connection': true,
13-
14-
'max reconnection attempts': Infinity,
15-
16-
'reconnection limit': 10 * 1000,
17-
18-
// Send auth token on connection
7+
// socket.io now auto-configures its connection when we ommit a connection url
8+
var ioSocket = io(null, {
9+
// Send auth token on connection, you will need to DI the Auth service above
1910
// 'query': 'token=' + Auth.getToken()
2011
});
2112

22-
retryTimer = setInterval(function () {
23-
if (!ioSocket.socket.connected &&
24-
!ioSocket.socket.connecting &&
25-
!ioSocket.socket.reconnecting) {
26-
ioSocket.connect();
27-
}
28-
}, retryInterval);
29-
3013
var socket = socketFactory({
3114
ioSocket: ioSocket
3215
});

Diff for: app/templates/server/config/_local.env.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ module.exports = {
1212
TWITTER_ID: "app-id",
1313
TWITTER_SECRET: "secret",
1414
GOOGLE_ID: "app-id",
15-
GOOGLE_SECRET: "secret"
15+
GOOGLE_SECRET: "secret",
16+
// Control debug level for modules using visionmedia/debug
17+
// DEBUG: ""
1618
};

Diff for: app/templates/server/config/socketio(socketio).js

+6-8
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,22 @@ function onConnect(socket) {
2222
}
2323

2424
module.exports = function (socketio) {
25-
// The amount of detail that the server should output to the logger.
26-
// 0 - error
27-
// 1 - warn
28-
// 2 - info
29-
// 3 - debug
30-
socketio.set('log level', 2);
25+
// socket.io (v1.x.x) is powered by debug.
26+
// In order to see all the debug output, set DEBUG (in server/config/local.env.js) to including the desired scope.
27+
//
28+
// ex: DEBUG: "http*,socket.io:socket"
3129

3230
// We can authenticate socket.io users and access their token through socket.handshake.decoded_token
3331
//
3432
// 1. You will need to send the token in `client/components/socket/socket.service.js`
3533
//
3634
// 2. Require authentication here:
37-
// socketio.set('authorization', require('socketio-jwt').authorize({
35+
// socketio.use(require('socketio-jwt').authorize({
3836
// secret: config.secrets.session,
3937
// handshake: true
4038
// }));
4139

42-
socketio.sockets.on('connection', function (socket) {
40+
socketio.on('connection', function (socket) {
4341
socket.address = socket.handshake.address.address + ':' +
4442
socket.handshake.address.port;
4543
socket.connectedAt = new Date();

0 commit comments

Comments
 (0)