Event Emitter memory leak! messages added twice! #4200
-
Beta Was this translation helpful? Give feedback.
Answered by
darrachequesne
Dec 6, 2021
Replies: 1 comment 4 replies
-
I think that's because a new listener gets added each time you receive a "msg" event on the server side. How about: io.on("connect", (socket) => {
socket.on("msg", (activechat, token, userlogin, message) => {
socket.emit(userlogin, "refresh")
})
socket.on(userlogin, (msg) => {
if (msg === "refresh ok") {
socket.emit(activechat, message)
}
})
}) |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
artstylee
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think that's because a new listener gets added each time you receive a "msg" event on the server side. How about: