Skip to content

Commit

Permalink
set gateway status to disconnected if closing
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Sep 15, 2024
1 parent e3c1055 commit 14192f3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ func (s Status) IsConnected() bool {
}
}

// String returns the string representation of the Status.
func (s Status) String() string {
switch s {
case StatusUnconnected:
return "Unconnected"
case StatusConnecting:
return "Connecting"
case StatusWaitingForHello:
return "WaitingForHello"
case StatusIdentifying:
return "Identifying"
case StatusResuming:
return "Resuming"
case StatusWaitingForReady:
return "WaitingForReady"
case StatusReady:
return "Ready"
case StatusDisconnected:
return "Disconnected"
default:
return "Unknown"
}
}

// Indicates how far along the client is too connecting.
const (
// StatusUnconnected is the initial state when a new Gateway is created.
Expand Down
1 change: 1 addition & 0 deletions gateway/gateway_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func (g *gatewayImpl) CloseWithCode(ctx context.Context, code int, message strin
g.config.LastSequenceReceived = nil
}
}
g.status = StatusDisconnected
}

func (g *gatewayImpl) Status() Status {
Expand Down

0 comments on commit 14192f3

Please sign in to comment.