(client) feat: Implement ProtoBuf and gRPC Client (#25)

This commit is contained in:
2025-07-14 16:54:10 +08:00
committed by m0_75251201
parent 4454a77bc7
commit 7b596e11e8
29 changed files with 1937 additions and 236 deletions

View File

@ -0,0 +1,19 @@
using Network;
using UnityEngine;
namespace Test
{
public class GrpcClientTest : MonoBehaviour
{
private async void Start()
{
var serverInfo = await GrpcClient.Instance.GetServerInfo();
Debug.Log($"Received info from server: {serverInfo}");
var loginResult = await GrpcClient.Instance.Login("野兽先辈", "114514");
Debug.Log($"Received login result: {loginResult.Result}");
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 98c1b145899d4d97bd981b177b5c45a9
timeCreated: 1752478138

View File

@ -1,26 +0,0 @@
using System.Threading.Tasks;
using Network;
using UnityEngine;
namespace Test
{
public class NetworkConnectionTest : MonoBehaviour
{
private async void Start()
{
await BasicTest();
}
private static async Task BasicTest()
{
var result = await UnityTcpClient.Instance.Connect("127.0.0.1", 12345);
if (result) Debug.Log("Connected to server!");
else Debug.LogError("Failed to connect to server!");
string buffer = null;
while (buffer is null) buffer = await UnityTcpClient.Instance.Receive();
Debug.Log($"Received contents: {buffer}");
}
}
}

View File

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 289a7efc822fe7347adfbf218522e8a2