Skip to content

Commit

Permalink
Revert source.js change
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchdev committed Nov 17, 2024
1 parent a7f8438 commit 02f4a10
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions assets/chat/js/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ class ChatSource extends EventEmitter {
}

parseAndDispatch(event) {
const { eventname, data } = this.parse(event);
this.emit('DISPATCH', { data, event: eventname }); // Event is used to hook into all dispatched events
this.emit(eventname, data);
}

parse(event) {
const eventname = event.data.split(' ', 1)[0].toUpperCase();
const payload = event.data.substring(eventname.length + 1);
let data = null;
Expand All @@ -105,12 +111,11 @@ class ChatSource extends EventEmitter {
} catch (ignored) {
data = payload;
}
this.dispatch(eventname, data);
}

dispatch(event, data) {
this.emit('DISPATCH', { event, data }); // Event is used to hook into all dispatched events
this.emit(event, data);
return {
eventname,
data,
};
}

send(eventname, data) {
Expand Down

0 comments on commit 02f4a10

Please sign in to comment.