()
| 20 | } |
| 21 | |
| 22 | disconnect(): void { |
| 23 | this.connecting = false; |
| 24 | |
| 25 | if (this.stream) { |
| 26 | const stream = this.stream; // Make sure callbacks refer to the same instance |
| 27 | |
| 28 | const timeout = setTimeout(() => { |
| 29 | debug( |
| 30 | "stream %s:%s still open, destroying it", |
| 31 | stream.remoteAddress, |
| 32 | stream.remotePort |
| 33 | ); |
| 34 | |
| 35 | stream.destroy(); |
| 36 | }, this.disconnectTimeout); |
| 37 | |
| 38 | stream.on("close", () => clearTimeout(timeout)); |
| 39 | stream.end(); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | abstract connect(_: ErrorEmitter): Promise<NetStream>; |
| 44 | } |