(client) feat:Add Network Connection Test Case (#6)

This commit is contained in:
2025-07-12 13:07:16 +08:00
parent 847fc9153e
commit d1ba4b8564
3 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,26 @@
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}");
}
}
}