If you have multiple namespaces or multiple instances of socket.io (like in the tests), you get multiple calls on a route for one socket call, because the router gets initialized once, globally.
With this fix, the router now gets initialized once per namespace object by checking if a router property already exists. The only way to change the constructor/function of socket.io/lib/namespace that came to my mind are doing dark things with the require cache, and I did not want to go there.
If you have multiple namespaces or multiple instances of socket.io (like in the tests), you get multiple calls on a route for one socket call, because the router gets initialized once, globally.
With this fix, the router now gets initialized once per namespace object by checking if a router property already exists. The only way to change the constructor/function of socket.io/lib/namespace that came to my mind are doing dark things with the require cache, and I did not want to go there.
Added a test for the echo route.