Added ITask and basic connection
This commit is contained in:
38
Assets/GameManager/GameManager_Network.cs
Normal file
38
Assets/GameManager/GameManager_Network.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using GeoSus.Client;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Subsystems
|
||||
{
|
||||
public class GameManager_Network
|
||||
{
|
||||
private const string _serverAddress = "geosus.honzuvkod.dev";
|
||||
private const int _serverPort = 7777;
|
||||
private GameClient _gameClient;
|
||||
public async void checkState()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Task<bool> state = _gameClient.ConnectAsync(_serverAddress, _serverPort);
|
||||
await state;
|
||||
if (state.Result)
|
||||
{
|
||||
Debug.Log("Connected to server.");
|
||||
_gameClient.Disconnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Failed to connect to server");
|
||||
}
|
||||
await Task.Delay(5000);
|
||||
}
|
||||
}
|
||||
public GameManager_Network(GameClient gameClient)
|
||||
{
|
||||
_gameClient = gameClient;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user