Reputation: 254
How can I simply remove an io.socket namespace?
delete io.nsps['/my_namespace'];
This doesn't prevent firering events from existing connected clients.
OK to point 1)
nsp= io.of('/my_namespace');
nsp.removeAllListeners("my_event"); //this doesnt' work
2.) Of course I could make an if statement for this,but I think this is not a clean solution.
3.)I don't know how to do this with a namespace without closing the complete socket(not just the namespace)) for the user.
My problem is,when I close a chat and delete all saving arrays and stuff, I get an error because events can still be fired(access on now undefined arrays,of course I could check if they exists but it was easier to just prevent events),like a send- or a disconnect- event.I don't want to prevent this on client-side,because of security issues.
Upvotes: 1
Views: 272
Reputation: 707318
It's still not very clear what you're really trying to do. To stop getting incoming socket events, you have a number of options:
As always, if you tell us what problem you're really trying to solve rather than just asking about the solution you're trying to implement, we may be able to offer much better answers. See a description of the XY Problem for discussion about why it may be better to ask about your actual problem rather than asking about issues with your attempted solution.
Upvotes: 1