예제 #1
0
 public void Play()
 {
     if (ENetClient.IsConnected())
     {
         SceneManager.LoadScene("Main");
         ENetClient.InGame = true;
     }
 }
예제 #2
0
        public void ConnectToRoom()
        {
            IGameplayConnection connection = new ENetClient(new ENetClientSettings
            {
                ServerHostName = "18.185.139.165",
                ServerPort     = 40002
            });

            networkService = new NetworkService(connection);

            connection.Connect();
        }
예제 #3
0
        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");
        }
예제 #4
0
 private void Start()
 {
     ENetClient.Connect(IP);
     StartCoroutine(CheckConnection());
 }