Exemplo n.º 1
0
        /// <summary>
        /// Command to start connecting to the server
        /// </summary>
        public void ConnectToServer()
        {
            // Setup variables
            string    networkAddress = serverAddress.text;
            IPAddress parsedAddress;
            ushort    networkPort;

            try
            {
                // Parse parameters
                IPAddress.TryParse(networkAddress, out parsedAddress);
                ushort.TryParse(serverPort.text, out networkPort);

                // Verify parameters
                // TODO: write verify code

                // Assign connection parameters
                PropHunt.Game.ProphuntClientServerControlSystem.NetworkAddress = networkAddress;
                PropHunt.Game.ProphuntClientServerControlSystem.NetworkPort    = networkPort;

                ConnectionSystem.ConnectToServer();
            }
            catch
            {
                UnityEngine.Debug.Log($"Failed to parse IP Address {serverAddress.text} and Port {serverPort.text}");
            }
        }
Exemplo n.º 2
0
        public IEnumerator ConnectionTest()
        {
            ConnectionSystem connectionManager = this.clientWorld.GetExistingSystem <ConnectionSystem>();

            yield return(null);

            // Make a connect request
            ConnectionSystem.ConnectToServer();
            yield return(new WaitForConnected(connectionManager));

            Assert.IsTrue(ConnectionSystem.IsConnected);

            yield return(null);

            // Make a disconnect request
            ConnectionSystem.DisconnectFromServer();
            yield return(new WaitForConnected(connectionManager, state: false));

            Assert.IsFalse(ConnectionSystem.IsConnected);
        }