public void Play() { if (ENetClient.IsConnected()) { SceneManager.LoadScene("Main"); ENetClient.InGame = true; } }
public void ConnectToRoom() { IGameplayConnection connection = new ENetClient(new ENetClientSettings { ServerHostName = "18.185.139.165", ServerPort = 40002 }); networkService = new NetworkService(connection); connection.Connect(); }
private IEnumerator CheckConnection() { while (!ENetClient.IsConnected()) { ConnectionAttempts++; Debug.Log($"Connection attempts: {ConnectionAttempts}"); if (ConnectionAttempts >= MAX_CONNECTION_ATTEMPTS) { Debug.Log("Failed after 10 connection attempts"); yield break; } yield return(new WaitForSeconds(CONNECTION_ATTEMPT_RETRY_DELAY)); } // Success ConnectionAttempts = 0; // Reset connection attempts / only fill it up again if client disconnects Debug.Log("Connection established"); }
private void Start() { ENetClient.Connect(IP); StartCoroutine(CheckConnection()); }