This commit is contained in:
mossimo
2021-07-30 15:39:13 +08:00
parent 424c0f7822
commit d2f56f5e9a
3 changed files with 10 additions and 10 deletions
@@ -49,7 +49,7 @@ namespace System.Net.WebSocket
/// 启动连接且尝试握手
/// </summary>
/// <returns>Task</returns>
internal async Task StartAsync(CancellationToken cancellationToken)
internal async Task StartAsync()
{
try
{
@@ -62,7 +62,7 @@ namespace System.Net.WebSocket
State = SocketState.Open;
if (OnConnected != null)
await OnConnected!.Invoke(new ConnectedEventArgs(this));
await Task.Run(() => ReadAsync(), cancellationToken);
await ReadAsync();
}
catch (SocketException e)
{
@@ -68,7 +68,7 @@ namespace System.Net.WebSocket
OnDisconnected = OnClientDisconnected
};
tokenSource.Token.Register(() => { client.Dispose(); });
await client.StartAsync(tokenSource.Token);
await client.StartAsync();
}, tokenSource.Token);
}
}
@@ -15,13 +15,13 @@ namespace System.Application.UI.ViewModels
partial class LoginOrRegisterWindowViewModel : WindowViewModel
{
ServerWebSocket server;
public override void Activation()
public override void Activation()
{
if (IsFirstActivation)
{
server = new ServerWebSocket("127.0.0.1", 9910);
server.OnClientReceived += handle;
server.Start();
server.Start();
}
base.Activation();
}
@@ -48,11 +48,11 @@ namespace System.Application.UI.ViewModels
if (IsBind)
{
await MainThread2.InvokeOnMainThreadAsync(async () =>
{
await UserService.Current.BindAccountAfterUpdateAsync(Channel, response.Content!);
var msg = AppResources.Success_.Format(AppResources.User_AccountBind);
Toast.Show(msg);
});
{
await UserService.Current.BindAccountAfterUpdateAsync(Channel, response.Content!);
var msg = AppResources.Success_.Format(AppResources.User_AccountBind);
Toast.Show(msg);
});
}
else
{