diff options
| author | JP Dillingham <jp@dillingham.me> | 2023-01-08 16:02:33 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2023-01-08 16:02:33 -0600 |
| commit | a37b61767410fea15aa8cf57c944ea23c495f6d4 (patch) | |
| tree | 6ffbf9ce84d0e03a10e00b95115b86bf6b3b0fdb /src | |
| parent | b61f219bf9e96721fe2df038af7e276e75ebe1e8 (diff) | |
| download | slskd-a37b61767410fea15aa8cf57c944ea23c495f6d4.tar.gz | |
reset logged in state in various places
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Relay/RelayClient.cs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/slskd/Relay/RelayClient.cs b/src/slskd/Relay/RelayClient.cs index 9d648b80..58bda800 100644 --- a/src/slskd/Relay/RelayClient.cs +++ b/src/slskd/Relay/RelayClient.cs @@ -206,8 +206,7 @@ namespace slskd.Relay { await HubConnection.StopAsync(cancellationToken); - LoggedIn = false; - + ResetLoggedInState(); State.SetValue(_ => TranslateState(HubConnectionState.Disconnected)); Log.Information("Relay controller connection disconnected"); @@ -511,15 +510,18 @@ namespace slskd.Relay private Task HubConnection_Closed(Exception arg) { Log.Warning("Relay controller connection closed: {Message}", arg.Message); - LoggedIn = false; - State.SetValue(_ => TranslateState(HubConnection.State)); + ResetLoggedInState(); + return Task.CompletedTask; } private Task HubConnection_Reconnected(string arg) { - // upon reconnection, the authentication flow is started again. - // there's nothing that needs to be done upon reconnection, only log. + // upon reconnection, the authentication flow is started again. this may happen before the client + // realizes the connection has been closed, so reset everything as though we're just learning that + // there has been a disconnect + ResetLoggedInState(); + Log.Warning("Relay controller connection reconnected"); return Task.CompletedTask; } @@ -527,6 +529,11 @@ namespace slskd.Relay private Task HubConnection_Reconnecting(Exception arg) { Log.Warning("Relay controller connection reconnecting: {Message}", arg.Message); + ResetLoggedInState(); + + return Task.CompletedTask; + } + private void ResetLoggedInState() { LoggedIn = false; |
