Update:Only emit library socket events to users with access to lib

This commit is contained in:
advplyr 2022-11-30 17:32:59 -06:00
parent 725f8eecdb
commit 0e292c64c4
3 changed files with 42 additions and 29 deletions

View file

@ -31,9 +31,13 @@ class SocketAuthority {
}
// Emits event to all authorized clients
emitter(evt, data) {
// optional filter function to only send event to specific users
// TODO: validate that filter is actually a function
emitter(evt, data, filter = null) {
for (const socketId in this.clients) {
if (this.clients[socketId].user) {
if (filter && !filter(this.clients[socketId].user)) continue
this.clients[socketId].socket.emit(evt, data)
}
}