From 84f2f96e127637cedab8a9b15d6f85e547970f0b Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 25 Feb 2023 22:46:34 -0500 Subject: [PATCH] *Change WS aliases to be conditional *Remove on/off aliases since streamx already provides it --- src/socket.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/socket.ts b/src/socket.ts index 1bcf738..56c3fd8 100644 --- a/src/socket.ts +++ b/src/socket.ts @@ -32,6 +32,10 @@ export default class Socket extends Duplex { public remotePublicKey: Uint8Array; private _emulateWebsocket: boolean; + declare addEventListener: typeof this.addListener; + declare removeEventListener: typeof this.removeListener; + declare send: typeof this.write; + constructor({ allowHalfOpen = false, remoteAddress, @@ -57,6 +61,9 @@ export default class Socket extends Duplex { } if (this._emulateWebsocket) { + this.addEventListener = this.addListener; + this.removeEventListener = this.removeListener; + this.send = this.write; this.addEventListener("data", (data: any) => // @ts-ignore this.emit("message", new MessageEvent("data", { data })) @@ -119,13 +126,6 @@ export default class Socket extends Duplex { }; } - addEventListener = this.addListener; - on = this.addListener; - removeEventListener = this.removeListener; - off = this.removeListener; - - send = write; - static isIP(input: string): number { if (Socket.isIPv4(input)) { return 4;