(tools, client, server) feat: Complete ProtoBuf message transmission with both TCP and UDP

This commit is contained in:
2025-08-30 21:25:17 +08:00
parent 362aa799b9
commit 450b15e4df
13 changed files with 149 additions and 35 deletions

View File

@ -8,6 +8,8 @@ namespace Network
{
public class UnityTcpClient : Singleton<UnityTcpClient>, IDisposable
{
private const int TcpMaxPayloadSize = 1460;
private TcpClient _client;
private bool _disposed;
@ -34,9 +36,9 @@ namespace Network
await stream.WriteAsync(data, 0, data.Length);
var buffer = new byte[1024];
await stream.ReadAsync(buffer);
return buffer;
var buffer = new byte[TcpMaxPayloadSize];
var len = await stream.ReadAsync(buffer);
return buffer[..len];
}
catch (Exception ex)
{