fix: use addEventListener, on is not available in all environments

This commit is contained in:
Derrick Hammer 2024-01-10 02:54:20 -05:00
parent 7d466b17c3
commit c4c0a947a9
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 3 deletions

View File

@ -74,7 +74,7 @@ export async function subscribeToEntry(
const socket = new WS(wsUrl); const socket = new WS(wsUrl);
socket.on("open", () => { socket.addEventListener("open", () => {
const packer = new Packer(); const packer = new Packer();
packer.pack(2); packer.pack(2);
packer.pack(publicKey); packer.pack(publicKey);
@ -84,8 +84,8 @@ export async function subscribeToEntry(
return { return {
listen(cb: (entry: SignedRegistryEntry) => void) { listen(cb: (entry: SignedRegistryEntry) => void) {
socket.on("message", (data) => { socket.addEventListener("message", (data) => {
cb(deserializeRegistryEntry(new Uint8Array(data as Buffer))); cb(deserializeRegistryEntry(new Uint8Array(data.data as Buffer)));
}); });
}, },
end() { end() {