Skip to content

Commit

Permalink
dont add duplicates to wsArr
Browse files Browse the repository at this point in the history
  • Loading branch information
ksentak committed Apr 20, 2023
1 parent 63dd940 commit 0297d10
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/src/events.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ function registerEventListener(userId, oMsg, ws) {
eventListenerMap[userId][oMsg.method] = { id: oMsg.id, wsArr: [] };
}

eventListenerMap[userId][oMsg.method].wsArr.push(ws);
// Check if ws is already in the wsArr before pushing
if (!eventListenerMap[userId][oMsg.method].wsArr.includes(ws)) {
eventListenerMap[userId][oMsg.method].wsArr.push(ws);
}

logger.debug(`Registered event listener mapping: ${userId}:${oMsg.method}:${oMsg.id}`);
}

Expand Down

0 comments on commit 0297d10

Please sign in to comment.