| 291 | }; |
| 292 | } |
| 293 | _destruct(reason) { |
| 294 | this._packetRW.read.cleanup(); |
| 295 | this._packetRW.write.cleanup(); |
| 296 | this._cipher && this._cipher.free(); |
| 297 | this._decipher && this._decipher.free(); |
| 298 | if (typeof reason !== 'string' || reason.length === 0) |
| 299 | reason = 'fatal error'; |
| 300 | this.parse = () => { |
| 301 | throw new Error(`Instance unusable after ${reason}`); |
| 302 | }; |
| 303 | this._onWrite = () => { |
| 304 | throw new Error(`Instance unusable after ${reason}`); |
| 305 | }; |
| 306 | this._destruct = undefined; |
| 307 | } |
| 308 | cleanup() { |
| 309 | this._destruct && this._destruct(); |
| 310 | } |