Exemplo n.º 1
0
        /// <summary>
        /// Stops the current mode of the NetworkManager
        /// </summary>
        private static void StopNetworkManagerMode()
        {
            switch (CurrentNetworkManagerMode)
            {
            case NetworkManagerOperatingMode.Host:
            {
                // Stop the host
                NetworkManagerObject.StopHost();
                break;
            }

            case NetworkManagerOperatingMode.Server:
            {
                // Stop the server
                NetworkManagerObject.StopServer();
                break;
            }

            case NetworkManagerOperatingMode.Client:
            {
                // Stop the client
                NetworkManagerObject.StopClient();
                break;
            }
            }

            Debug.Log($"{CurrentNetworkManagerMode} stopped.");
            CurrentNetworkManagerMode = NetworkManagerOperatingMode.None;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts the NetworkManager in the current mode specified by managerMode
        /// </summary>
        /// <param name="managerMode">the mode to start the NetworkManager as</param>
        private static void StartNetworkManagerMode(NetworkManagerOperatingMode managerMode)
        {
            CurrentNetworkManagerMode = managerMode;
            switch (CurrentNetworkManagerMode)
            {
            case NetworkManagerOperatingMode.Host:
            {
                // Starts the host
                NetworkManagerObject.StartHost();
                break;
            }

            case NetworkManagerOperatingMode.Server:
            {
                // Starts the server
                NetworkManagerObject.StartServer();
                break;
            }

            case NetworkManagerOperatingMode.Client:
            {
                // Starts the client
                NetworkManagerObject.StartClient();
                break;
            }
            }

            // If we started an MLAPI session
            if (CurrentNetworkManagerMode != NetworkManagerOperatingMode.None)
            {
                // With some unit tests the Singleton can still be from a previous unit test
                // depending upon the order of operations that occurred.
                if (NetworkManager.Singleton != NetworkManagerObject)
                {
                    NetworkManagerObject.SetSingleton();
                }

                // Only log this if we started an MLAPI session
                Debug.Log($"{CurrentNetworkManagerMode} started.");
            }
        }