Skip to content

Commit

Permalink
switch to decoder next
Browse files Browse the repository at this point in the history
  • Loading branch information
webdev03 committed Oct 15, 2023
1 parent 742f461 commit 2aa44c8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/classes/cloud/PacketCloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ class PacketCloud extends events.EventEmitter {
super();
this.connection = connection;
this.connection.on("set", (data) => {
if (String(data.name).includes("FROM_USER_")) {
const [name, value] = [...decode(data.value)];
for(const fn of this.onRequestListeners) fn(name, value);
if (String(data.name).includes("FROM_USER")) {
const decoder = decode(data.value);
const name = decoder.next().value;
const value = decoder.next().value;
if(!name || !value) return;
for(const fn of this.onRequestListeners) try { fn(name, value) } catch(e) { console.error(e) };
this.emit(name, value);
}
});
Expand Down

0 comments on commit 2aa44c8

Please sign in to comment.