Emitting socket.io events from models and controllers in Geddy is pretty simple:
geddy.io.sockets.emit
will emit an event to all connected clients
If you want to listen for events from, or send events to specific clients, you'll need to create an after_start.js
file in your app's config directory, and use geddy.io
like you would normally use socket.io
:
geddy.io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});