Fix some bugs caused by order of operations.
This commit is contained in:
@@ -112,16 +112,17 @@ public class AccountManager
|
||||
|
||||
public async Task LogoutAsync()
|
||||
{
|
||||
await accountState.SetUser(null);
|
||||
var platform = await localStorage.GetAccountPlatform();
|
||||
await localStorage.DeleteAccountPlatform();
|
||||
|
||||
if (platform == WhichAccountPlatform.Guest)
|
||||
{
|
||||
await shogiApi.GuestLogout();
|
||||
await accountState.SetUser(null);
|
||||
}
|
||||
else if (platform == WhichAccountPlatform.Microsoft)
|
||||
{
|
||||
await accountState.SetUser(null);
|
||||
navigation.NavigateToLogout("authentication/logout");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,14 @@ public class ShogiSocket : IDisposable
|
||||
|
||||
public async Task OpenAsync(string token)
|
||||
{
|
||||
uriBuilder.Query = new QueryBuilder
|
||||
if (this.socket.State == WebSocketState.Open)
|
||||
{
|
||||
{ "token", token }
|
||||
}.ToQueryString().Value;
|
||||
await this.socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing before opening a new connection.", CancellationToken.None);
|
||||
}
|
||||
|
||||
uriBuilder.Query = new QueryBuilder { { "token", token } }.ToQueryString().Value;
|
||||
|
||||
Console.WriteLine("ShogiSocket.OpenAsync socket state is {0}", this.socket.State.ToString());
|
||||
|
||||
await socket.ConnectAsync(this.uriBuilder.Uri, cancelToken.Token);
|
||||
// Fire and forget! I'm way too lazy to write my own javascript interop to a web worker. Nooo thanks.
|
||||
@@ -102,8 +106,8 @@ public class ShogiSocket : IDisposable
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
//socket.Dispose(); // This is handled by the DI container.
|
||||
cancelToken.Cancel();
|
||||
socket.Dispose();
|
||||
memoryOwner.Dispose();
|
||||
}
|
||||
disposedValue = true;
|
||||
|
||||
Reference in New Issue
Block a user