0

I referred Socket.io : How do I handle all incoming messages on the server? answered by Ganesh Kumar to override the on() but i am unable to pass a callback function as argument. Why is it so? Can't i pass callback function in this?

My code snippet is like:

socket.$emit = function(callback)
{
   ....
   callback()
}

It is flagging error and treating callback as string. Am I doing something wrong?

Community
  • 1
  • 1
nebi
  • 727
  • 3
  • 9
  • 24

1 Answers1

0

In the regular emit function you cannot pass a callback.

In the overridden version you can only accept the same arguments as the regular version.

Naftali
  • 144,921
  • 39
  • 244
  • 303