Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

do I have to remove event listener when socket is disconnected?

In socket.io, when the client is disconnected from the server the disconnect event is fired in the server for the socket. Do I have to removeAllEventListeners() from the socket $events? Or does it happen automatically when the socket dies? I heard that memory leaks can be on the server if i don't do it ...

like image 627
udidu Avatar asked Nov 17 '12 12:11

udidu


1 Answers

After digging through the socket.io source, the socket object (which is the EventEmitter) is deleted when the client disconnects so it is not necessary to manually call removeAllListeners.

like image 92
Timothy Strimple Avatar answered Oct 23 '22 12:10

Timothy Strimple