fix: correctly reset session

This commit is contained in:
alina 🌸 2024-03-28 18:59:21 +03:00
parent d577f0ed9b
commit fa267eef03
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
3 changed files with 3 additions and 3 deletions

View file

@ -79,12 +79,12 @@ export abstract class BaseTcpTransport extends EventEmitter implements ITelegram
if (this._state === TransportState.Idle) return
this.log.info('connection closed')
this.emit('close')
this._state = TransportState.Idle
this._socket?.end()
this._socket = null
this._currentDc = null
this._packetCodec.reset()
this.emit('close')
}
handleError(socket: unknown, error: Error): void {

View file

@ -73,13 +73,13 @@ export abstract class BaseTcpTransport extends EventEmitter implements ITelegram
if (this._state === TransportState.Idle) return
this.log.info('connection closed')
this.emit('close')
this._state = TransportState.Idle
this._socket!.removeAllListeners()
this._socket!.destroy()
this._socket = null
this._currentDc = null
this._packetCodec.reset()
this.emit('close')
}
handleError(error: Error): void {

View file

@ -130,13 +130,13 @@ export abstract class BaseWebSocketTransport extends EventEmitter implements ITe
if (this._state === TransportState.Idle) return
this.log.info('connection closed')
this.emit('close')
this._state = TransportState.Idle
this._socket!.removeEventListener('close', this.close)
this._socket!.close()
this._socket = null
this._currentDc = null
this._packetCodec.reset()
this.emit('close')
}
handleError(event: Event | { error: Error }): void {