sending a socket.io .once message

Viewed 15552

This would work without the .once call.

I am trying to send a single message from server side code with

io.on('connect', function (socket) { socket.once('connect', function() { socket.emit('mydata', { feed: result});

but I get nothing on the client side unless I remove the second line. I also tried socket.once('mydata', { feed: result}) but:

throw new TypeError('listener must be a function');

In other words how can one send a message to the client side only when there is new 'mydata'?

Thanks

2 Answers
Related