1
This commit is contained in:
@@ -48,14 +48,17 @@ namespace BITKit.Net
|
||||
});
|
||||
}
|
||||
|
||||
private async void Tick(object sender, ElapsedEventArgs e)
|
||||
private void Tick(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
await UniTask.SwitchToThreadPool();
|
||||
//await UniTask.SwitchToThreadPool();
|
||||
while (commandQueue.TryDequeue(out var bytes))
|
||||
{
|
||||
client.Send(bytes, KcpChannel.Reliable);
|
||||
}
|
||||
client.Tick();
|
||||
//for (var i = 0; i < 32; i++)
|
||||
{
|
||||
client.Tick();
|
||||
}
|
||||
}
|
||||
|
||||
public async void Disconnect()
|
||||
@@ -88,6 +91,10 @@ namespace BITKit.Net
|
||||
if (BITApp.SynchronizationContext is not null)
|
||||
await UniTask.SwitchToSynchronizationContext(BITApp.SynchronizationContext);
|
||||
OnConnected?.Invoke();
|
||||
if (client.connected)
|
||||
{
|
||||
SendServerMessage(Environment.MachineName);
|
||||
}
|
||||
return client.connected;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -136,7 +143,7 @@ namespace BITKit.Net
|
||||
|
||||
break;
|
||||
case NetCommandType.Heartbeat:
|
||||
//client.Send(new[] { (byte)NetCommandType.Heartbeat }, KcpChannel.Reliable);
|
||||
client.Send(new[] { (byte)NetCommandType.Heartbeat }, KcpChannel.Reliable);
|
||||
break;
|
||||
default:
|
||||
BIT4Log.Log<KcpClient>($"未知消息类型:{type},字节:{(byte)type}");
|
||||
|
Reference in New Issue
Block a user