Update KcpNetClient.cs
This commit is contained in:
parent
b368e8258b
commit
22f318c8f6
|
@ -67,9 +67,16 @@ namespace BITKit.Net
|
||||||
|
|
||||||
private async void ConnectionCallback(bool x)
|
private async void ConnectionCallback(bool x)
|
||||||
{
|
{
|
||||||
if (x is false) return;
|
|
||||||
await UniTask.SwitchToSynchronizationContext(BITApp.SynchronizationContext);
|
await UniTask.SwitchToSynchronizationContext(BITApp.SynchronizationContext);
|
||||||
OnConnected?.Invoke();
|
if (x)
|
||||||
|
{
|
||||||
|
OnConnected?.Invoke();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnDisconnected?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Tick(object sender, ElapsedEventArgs e)
|
private void Tick(object sender, ElapsedEventArgs e)
|
||||||
|
@ -290,7 +297,7 @@ namespace BITKit.Net
|
||||||
|
|
||||||
private async void OnDisconnectInternal()
|
private async void OnDisconnectInternal()
|
||||||
{
|
{
|
||||||
BIT4Log.Log<KcpNetClient>("断开连接");
|
//BIT4Log.Log<KcpNetClient>("断开连接");
|
||||||
_timer.Stop();
|
_timer.Stop();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -298,7 +305,6 @@ namespace BITKit.Net
|
||||||
await UniTask.SwitchToSynchronizationContext(BITApp.SynchronizationContext,
|
await UniTask.SwitchToSynchronizationContext(BITApp.SynchronizationContext,
|
||||||
BITApp.CancellationToken);
|
BITApp.CancellationToken);
|
||||||
_isConnected.RemoveElement(this);
|
_isConnected.RemoveElement(this);
|
||||||
OnDisconnected?.Invoke();
|
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue