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

ぐ巨炮叔叔 提交于 2020-01-12 06:56:50

问题


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 ...


回答1:


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.



来源:https://stackoverflow.com/questions/13430505/do-i-have-to-remove-event-listener-when-socket-is-disconnected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!