This commit is contained in:
CortexCore
2023-08-11 23:57:37 +08:00
parent 936a94c84b
commit 75889ec34f
149 changed files with 6524 additions and 1043 deletions

View File

@@ -29,9 +29,9 @@ namespace BITKit.Net
client.Disconnect();
OnDisconnected?.Invoke();
}
public async UniTask<bool> Connect(string address = "localhost", ushort port = 27014)
{
OnStartConnect?.Invoke();
await UniTask.SwitchToThreadPool();
try
{
@@ -50,11 +50,11 @@ namespace BITKit.Net
private void OnData(ArraySegment<byte> bytes, KcpChannel channel)
{
var command = BITBinary.ReadAsValue(bytes.ToArray());
BIT4Log.Log<KCPNetServer>($"已收到指令:command");
BIT4Log.Log<KCPNetServer>($"已收到指令:{command}");
}
private void OnConnectedInternal()
{
OnConnected?.Invoke();;
OnConnected?.Invoke();
BIT4Log.Log<KcpNetClient>("已连接");
}
private void OnDisconnectInternal()
@@ -126,7 +126,7 @@ namespace BITKit.Net
{
var bytes = BinaryBuilder
.Create()
.Write((byte)NetCommandType.TargetCommand)
.Write((byte)commandType)
.Write(values)
.Build();
client.Send(bytes, KcpChannel.Reliable);