express.io
express.io copied to clipboard
How do you pass a callback to emit to express.io.route
With pure socket io, I can pass callback to emit as follows:
server side: socket.on('data', function(data, callback) { process data from client; callback && callback(true); }
client side: socket.emit('data', {name:value}, function(data) { console.log('The server got something'); }
But if I use express.io on the server side, the below code does not work because the callback is null. express.io.route('data', function(req, callback) { process data from client; callback && callback(true); <--- This does not work because callback is undefined }
So how do I do the callback to client side's emit on the server side using expressio?
needed this functionality too, trying this:
app.io.route('ready', function (socket) {
console.log('Client connected');
socket.io.emit('news', { hello: 'world' });
socket.io.route('my other event', function (data) {
console.log(data);
});
});
gives "undefined is not a function" error