Last active
October 13, 2015 05:26
-
-
Save rjmacarthy/804af030d82bafb975be to your computer and use it in GitHub Desktop.
Sails.js Socket.io Configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
socket = io.connect(); | |
socket.on('connect', function socketConnected() { | |
socket.on('sockets', function newMessageFromSails ( data ) { | |
console.log(data); // Data from socket | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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