Add client test case
This commit is contained in:
26
Client/Assets/Scripts/Test/NetworkConnectionTest.cs
Normal file
26
Client/Assets/Scripts/Test/NetworkConnectionTest.cs
Normal 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}");
|
||||
}
|
||||
}
|
||||
}
|
2
Client/Assets/Scripts/Test/NetworkConnectionTest.cs.meta
Normal file
2
Client/Assets/Scripts/Test/NetworkConnectionTest.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 289a7efc822fe7347adfbf218522e8a2
|
Reference in New Issue
Block a user