Re-work socket and reconnection/status logic

This commit is contained in:
Jon Staab
2024-05-22 17:33:20 -07:00
parent f8d74f5984
commit c5e3f6d5a4
3 changed files with 46 additions and 68 deletions
+4 -1
View File
@@ -159,10 +159,13 @@ export class ConnectionMeta {
getSpeed = () => this.responseCount ? this.responseTimer / this.responseCount : 0
getStatus = () => {
const socket = this.cxn.socket
if (this.authStatus === AuthStatus.Unauthorized) return ConnectionStatus.Unauthorized
if (this.authStatus === AuthStatus.Forbidden) return ConnectionStatus.Forbidden
if (socket.isNew()) return ConnectionStatus.Closed
if (this.lastFault && this.lastFault > this.lastOpen) return ConnectionStatus.Error
if (this.lastClose > this.lastOpen) return ConnectionStatus.Closed
if (socket.isClosed() || socket.isClosing()) return ConnectionStatus.Closed
if (this.getSpeed() > 1000) return ConnectionStatus.Slow
return ConnectionStatus.Ok