Skip to content

Commit

Permalink
fix: broadcastBrowser defaults to true
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Oct 19, 2023
1 parent 238ba86 commit 4ea5a08
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@
if (message && message.uid) {
if (isBrowser) {
var event = new window.CustomEvent(message.uid, {
detail: data
detail: message
});
window.dispatchEvent(event);
} else {
process.emit(message.uid, message);
}
}

self.__fireListeners(message.method, message)
self.__fireListeners(message)
} catch (e) {
console.log(e);
}
Expand All @@ -265,11 +265,8 @@
}
},

__fireListeners(action, data) {
const listeners = this.listeners.get(action);
if (!listeners) {
return;
}
__fireListeners(data) {
const listeners = this.listeners.get(data.method) || [];
listeners.forEach(listener => {
listener(data);
});
Expand Down Expand Up @@ -349,10 +346,12 @@
delete data.room;

let broadcastBrowser = false
if (data['broadcastBrowser'] && data['broadcastBrowser'] !== 'false') {
if (data['broadcastBrowser'] === 'false' && data['broadcastBrowser'] === false)
broadcastBrowser = false;
else
broadcastBrowser = true;
delete data['broadcastBrowser']
}

delete data['broadcastBrowser']

const uid = data['uid'];
const sockets = await this.getSockets(data);
Expand Down Expand Up @@ -507,7 +506,7 @@
},

sendLocalMessage(data) {
this.__fireListeners(data.method, data)
this.__fireListeners(data)
},

// TODO: add to ObjectId function
Expand Down

0 comments on commit 4ea5a08

Please sign in to comment.