*Create event forwards after socket is created

This commit is contained in:
Derrick Hammer 2023-04-15 05:45:07 -04:00
parent cb42eae011
commit 998d05a74c
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 8 additions and 8 deletions

View File

@ -58,14 +58,6 @@ export class TCPSocket extends Duplex {
}
public connect() {
["timeout", "error", "connect", "end", "destroy", "close"].forEach(
(event) => {
this._socket?.on(event, (...args: any) =>
this.emit(event as any, ...args)
);
}
);
this.on("error", (err: Error) => {
this._peer.messages.errorSocket?.send({
...this._getSocketRequest(),
@ -88,6 +80,14 @@ export class TCPSocket extends Duplex {
}
this._socket = net.connect(this._options);
["timeout", "error", "connect", "end", "destroy", "close"].forEach(
(event) => {
this._socket?.on(event, (...args: any) =>
this.emit(event as any, ...args)
);
}
);
this._socket.pipe(this as any);
this.pipe(this._socket);
}