Skip to content

Commit 14192f3

Browse files
committed
set gateway status to disconnected if closing
1 parent e3c1055 commit 14192f3

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

gateway/gateway.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@ func (s Status) IsConnected() bool {
2121
}
2222
}
2323

24+
// String returns the string representation of the Status.
25+
func (s Status) String() string {
26+
switch s {
27+
case StatusUnconnected:
28+
return "Unconnected"
29+
case StatusConnecting:
30+
return "Connecting"
31+
case StatusWaitingForHello:
32+
return "WaitingForHello"
33+
case StatusIdentifying:
34+
return "Identifying"
35+
case StatusResuming:
36+
return "Resuming"
37+
case StatusWaitingForReady:
38+
return "WaitingForReady"
39+
case StatusReady:
40+
return "Ready"
41+
case StatusDisconnected:
42+
return "Disconnected"
43+
default:
44+
return "Unknown"
45+
}
46+
}
47+
2448
// Indicates how far along the client is too connecting.
2549
const (
2650
// StatusUnconnected is the initial state when a new Gateway is created.

gateway/gateway_impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ func (g *gatewayImpl) CloseWithCode(ctx context.Context, code int, message strin
154154
g.config.LastSequenceReceived = nil
155155
}
156156
}
157+
g.status = StatusDisconnected
157158
}
158159

159160
func (g *gatewayImpl) Status() Status {

0 commit comments

Comments
 (0)