1
This commit is contained in:
@@ -11,6 +11,7 @@ using System.Numerics;
|
||||
using System.Reflection;
|
||||
using BITKit.Net.Examples;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace BITKit.Net
|
||||
{
|
||||
@@ -21,7 +22,7 @@ namespace BITKit.Net
|
||||
public event Action OnDisconnected;
|
||||
public event Action OnConnectedFailed;
|
||||
public bool IsConnected => client.connected;
|
||||
|
||||
public float2 Traffic { get; set; }
|
||||
public bool ManualTick { get; set; }
|
||||
|
||||
public int Ping { get; private set; }
|
||||
@@ -111,6 +112,7 @@ namespace BITKit.Net
|
||||
await Task.Delay(100);
|
||||
}
|
||||
_timer.Start();
|
||||
Traffic+=new float2(1,0);
|
||||
client.Send(new[] { (byte)NetCommandType.Heartbeat }, KcpChannel.Reliable);
|
||||
if (BITApp.SynchronizationContext is not null)
|
||||
await UniTask.SwitchToSynchronizationContext(BITApp.SynchronizationContext);
|
||||
@@ -144,6 +146,7 @@ namespace BITKit.Net
|
||||
{
|
||||
try
|
||||
{
|
||||
Traffic+=new float2(0,bytes.Count);
|
||||
OnDataInternel(bytes, channel);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -187,6 +190,7 @@ namespace BITKit.Net
|
||||
|
||||
break;
|
||||
case NetCommandType.Heartbeat:
|
||||
Traffic+=new float2(1,0);
|
||||
client.Send(new[] { (byte)NetCommandType.Heartbeat }, KcpChannel.Reliable);
|
||||
_isConnected.AddElement(this);
|
||||
break;
|
||||
@@ -450,6 +454,7 @@ namespace BITKit.Net
|
||||
.Write(((byte)NetCommandType.Message))
|
||||
.Write(message)
|
||||
.Build();
|
||||
Traffic+=new float2(bytes.Length,0);
|
||||
client.Send(bytes, KcpChannel.Reliable);
|
||||
}
|
||||
|
||||
@@ -463,6 +468,7 @@ namespace BITKit.Net
|
||||
{
|
||||
while (commandQueue.TryDequeue(out var bytes))
|
||||
{
|
||||
Traffic+=new float2(bytes.Length,0);
|
||||
client.Send(bytes, KcpChannel.Reliable);
|
||||
}
|
||||
|
||||
@@ -486,6 +492,7 @@ namespace BITKit.Net
|
||||
public void HandShake()
|
||||
{
|
||||
// send client to server
|
||||
Traffic+=new float2(2,0);
|
||||
client.Send(new byte[]{0x01, 0x02}, KcpChannel.Reliable);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user