Skip to content
This repository was archived by the owner on Jul 29, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"passport-google-oauth": "latest",<% } %>
"composable-middleware": "^0.3.0",
"connect-mongo": "^0.4.1"<% if(filters.socketio) { %>,
"socket.io": "~1.0.6",
"socket.io": "^1.0.6",
"socket.io-client": "^1.0.6",
"socketio-jwt": "^2.0.2"<% } %>
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ angular.module '<%= scriptAppName %>'

# socket.io now auto-configures its connection when we omit a connection url
ioSocket = io '',
'reconnection limit': 10 * 1000
# Send auth token on connection, you will need to DI the Auth service above
# 'query': 'token=' + Auth.getToken()
path: '/socket.io-client'

socket = socketFactory ioSocket: ioSocket

Expand Down Expand Up @@ -64,4 +64,4 @@ angular.module '<%= scriptAppName %>'
###
unsyncUpdates: (modelName) ->
socket.removeAllListeners modelName + ':save'
socket.removeAllListeners modelName + ':remove'
socket.removeAllListeners modelName + ':remove'
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ angular.module('<%= scriptAppName %>')
var ioSocket = io('', {
// Send auth token on connection, you will need to DI the Auth service above
// 'query': 'token=' + Auth.getToken()
path: '/socket.io-client'
});

var socket = socketFactory({
Expand Down Expand Up @@ -70,4 +71,4 @@ angular.module('<%= scriptAppName %>')
socket.removeAllListeners(modelName + ':remove');
}
};
});
});
4 changes: 2 additions & 2 deletions app/templates/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/json3/lib/json3.min.js"></script>
<![endif]-->
<% if(filters.socketio) { %> <script src="socket.io/socket.io.js"></script><% } %>
<!-- build:js(client) app/vendor.js -->
<!-- build:js({client<% if(filters.socketio) { %>,node_modules<% } %>}) app/vendor.js -->
<!-- bower:js -->
<!-- endbower -->
<% if(filters.socketio) { %><script src="socket.io-client/socket.io.js"></script><% } %>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kingcody What happens, here? I'm confused.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We moved the socket.io script tag inside the usemin build block so it will get included in vendor.js. We add node_modules to the search glob for the build, and change the path to socket.io-client/... since we install socket.io-client as a dependency. That way the paths all line up nicely and we still use the same script that socket.io would serve.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thank you :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you take a look at the server and client scripts where we setup socket.io, you should see where we've adjusted the paths to match.

<!-- endbuild -->

<!-- build:js({.tmp,client}) app/app.js -->
Expand Down
7 changes: 5 additions & 2 deletions app/templates/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ if(config.seedDB) { require('./config/seed'); }
<% } %>// Setup server
var app = express();
var server = require('http').createServer(app);<% if (filters.socketio) { %>
var socketio = require('socket.io').listen(server);
var socketio = require('socket.io')(server, {
serveClient: (config.env === 'production') ? false : true,
path: '/socket.io-client'
});
require('./config/socketio')(socketio);<% } %>
require('./config/express')(app);
require('./routes')(app);
Expand All @@ -31,4 +34,4 @@ server.listen(config.port, config.ip, function () {
});

// Expose app
exports = module.exports = app;
exports = module.exports = app;