Skip to content

Instantly share code, notes, and snippets.

@rjmacarthy
Last active October 13, 2015 05:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjmacarthy/804af030d82bafb975be to your computer and use it in GitHub Desktop.
Save rjmacarthy/804af030d82bafb975be to your computer and use it in GitHub Desktop.
Sails.js Socket.io Configuration
socket = io.connect();
socket.on('connect', function socketConnected() {
socket.on('sockets', function newMessageFromSails ( data ) {
console.log(data); // Data from socket
});
});
module.exports = {
sockets : function (req, res){
var socket = req.socket;
var io = sails.io;
Model.find(function(err, models){
io.sockets.emit('sockets', models);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment