StartServer() public method

This starts a new server.

public StartServer ( ) : bool
return bool
コード例 #1
0
 public void ServerButton()
 {
     if (UnityEngine.Application.platform != RuntimePlatform.WebGLPlayer)
     {
         manager.StartServer();
     }
 }
コード例 #2
0
        void Update()
        {
            if (!showGUI)
            {
                return;
            }

            if (!manager.IsClientConnected() && !NetworkServer.active && manager.matchMaker == null)
            {
                if (Input.GetKeyDown(KeyCode.S))
                {
                    manager.StartServer();
                }
                if (Input.GetKeyDown(KeyCode.H))
                {
                    manager.StartHost();
                }
                if (Input.GetKeyDown(KeyCode.C))
                {
                    manager.StartClient();
                }
            }
            if (NetworkServer.active && manager.IsClientConnected())
            {
                if (Input.GetKeyDown(KeyCode.X))
                {
                    manager.StopHost();
                }
            }
        }
コード例 #3
0
ファイル: NewHUD.cs プロジェクト: csun22/PlaygroundE
        void Update()
        {
            if (!showGUI)
            {
                return;
            }

            if (!manager.IsClientConnected() && !NetworkServer.active && manager.matchMaker == null)
            {
                if (UnityEngine.Application.platform != RuntimePlatform.WebGLPlayer)
                {
                    if (Input.GetKeyDown(KeyCode.S))
                    {
                        manager.StartServer();
                    }
                    if (Input.GetKeyDown(KeyCode.H))
                    {
                        manager.StartHost();
                    }
                }
                if (Input.GetKeyDown(KeyCode.C))
                {
                    manager.StartClient();
                }
            }
            if (NetworkServer.active && manager.IsClientConnected())
            {
                if (Input.GetKeyDown(KeyCode.X))
                {
                    manager.StopHost();
                }
            }
        }
コード例 #4
0
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                isPaused = !isPaused;
            }


            if (isPaused)
            {
                Time.timeScale = 0f;                 // Le temps s'arrete
            }
            else
            {
                Time.timeScale = 1.0f;                 // Le temps reprend
            }
            if (!showGUI)
            {
                return;
            }

            if (!manager.IsClientConnected() && !NetworkServer.active && manager.matchMaker == null)
            {
                if (UnityEngine.Application.platform != RuntimePlatform.WebGLPlayer)
                {
                    if (Input.GetKeyDown(KeyCode.S))
                    {
                        manager.StartServer();
                    }
                    if (Input.GetKeyDown(KeyCode.H))
                    {
                        manager.StartHost();
                    }
                }
                if (Input.GetKeyDown(KeyCode.C))
                {
                    manager.StartClient();
                }
            }
            if (NetworkServer.active && manager.IsClientConnected())
            {
                if (Input.GetKeyDown(KeyCode.X))
                {
                    manager.StopHost();
                }
            }
        }
コード例 #5
0
        void Update()

        {
            // if (!showGUI)

            // return;


            if (!NetworkClient.active && !NetworkServer.active && manager.matchMaker == null)

            {
                if (Input.GetKeyDown(KeyCode.S))

                {
                    manager.StartServer();
                }

                if (Input.GetKeyDown(KeyCode.H))

                {
                    manager.StartHost();
                }

                if (Input.GetKeyDown(KeyCode.C))

                {
                    manager.StartClient();
                }
            }

            if (NetworkServer.active && NetworkClient.active)

            {
                if (Input.GetKeyDown(KeyCode.X))

                {
                    manager.StopHost();
                }
            }
        }
コード例 #6
0
        public void Update()
        {
            if ((NetworkClient.active || NetworkServer.active) && Input.GetKeyUp(KeyCode.Escape))
            {
                this.showGUI = !this.showGUI;
            }

            if (!showGUI)
            {
                return;
            }

            if (!NetworkClient.active && !NetworkServer.active && manager.matchMaker == null)
            {
                if (Input.GetKeyDown(KeyCode.S))
                {
                    this.showGUI = false;
                    manager.StartServer();
                }
                if (Input.GetKeyDown(KeyCode.H))
                {
                    this.showGUI = false;
                    manager.StartHost();
                }
                if (Input.GetKeyDown(KeyCode.C))
                {
                    manager.StartClient();
                }
            }
            if (NetworkServer.active && NetworkClient.active)
            {
                if (Input.GetKeyDown(KeyCode.K))
                {
                    manager.StopHost();
                    this.showGUI = true;
                }
            }
        }
コード例 #7
0
ファイル: customHUD.cs プロジェクト: 405410049/unity-project
 public void StartServer()
 {
     manager.StartServer();
 }
コード例 #8
0
 private void Start()
 {
     manager.StartServer();
 }
コード例 #9
0
        void Update()
        {
            /*if ((!NetworkClient.active || (NetworkClient.active && !ClientScene.ready)) && !host) {
             *      timerClient -= Time.deltaTime;
             *      if (timerClient <= 0f) {
             *              startClient (ipAddress);
             *              print ("START CLIENT");
             *
             *              timerClient = timerReconnect;
             *      }
             * }*/

            if (controllerGame.GetComponent <ControllerGaming> ().endMatch)
            {
                timerMenu -= Time.deltaTime;

                if (Input.GetButtonDown("XboxA") || timerMenu <= 0f)
                {
                    stopHost();
                    stopClient();

                    Destroy(GameObject.Find("NetVehicleContainer"));

                    SceneManager.LoadScene("Main menu");
                }
            }

            int numPlayers = lobby.GetComponent <Lobby> ().activePlayers;
            int maxPlayers = GetComponent <ControllerNet> ().maxPlayers;

            if (numPlayers != maxPlayers)
            {
                if (Input.GetButtonDown("XboxB"))
                {
                    stopHost();
                    stopClient();

                    Destroy(GameObject.Find("NetVehicleContainer"));

                    SceneManager.LoadScene("Main menu");
                }
            }

            if (!showGUI)
            {
                return;
            }

            if (!NetworkClient.active && !NetworkServer.active && manager.matchMaker == null)
            {
                if (Input.GetKeyDown(KeyCode.S))
                {
                    manager.StartServer();
                }
                if (Input.GetKeyDown(KeyCode.H))
                {
                    manager.StartHost();
                }
                if (Input.GetKeyDown(KeyCode.C))
                {
                    manager.StartClient();
                }
            }
            if (NetworkServer.active && NetworkClient.active)
            {
                if (Input.GetKeyDown(KeyCode.X))
                {
                    manager.StopHost();
                }
            }
        }
コード例 #10
0
        void OnGUI()
        {
            int xpos         = 25;
            int ypos         = 50;
            int buttonWidth  = 400;
            int buttonHeight = 100;
            int spacing      = buttonHeight + 10;

            bool noConnection = (manager.client == null || manager.client.connection == null ||
                                 manager.client.connection.connectionId == -1);

            if (!manager.IsClientConnected() && !NetworkServer.active)
            {
                if (noConnection)
                {
                    if (GUI.Button(new Rect(xpos, ypos, buttonWidth, buttonHeight), "LAN Host(H)"))
                    {
                        manager.StartHost();
                    }
                    ypos += spacing;

                    if (GUI.Button(new Rect(xpos, ypos, buttonWidth / 2, buttonHeight), "LAN Client(C)"))
                    {
                        manager.StartClient();
                    }
                    manager.networkAddress = GUI.TextField(new Rect(xpos + buttonWidth / 2, ypos, buttonWidth / 2, buttonHeight), manager.networkAddress);
                    ypos += spacing;

                    if (GUI.Button(new Rect(xpos, ypos, buttonWidth, buttonHeight), "LAN Server Only(S)"))
                    {
                        manager.StartServer();
                    }
                    ypos += spacing;
                }
                else
                {
                    GUI.Label(new Rect(xpos, ypos, buttonWidth, buttonHeight), "Connecting to " + manager.networkAddress + ":" + manager.networkPort + "..");
                    ypos += spacing;


                    if (GUI.Button(new Rect(xpos, ypos, buttonWidth, buttonHeight), "Cancel Connection Attempt"))
                    {
                        manager.StopClient();
                    }
                }
            }
            else
            {
                if (NetworkServer.active)
                {
                    string serverMsg = "Server: port=" + manager.networkPort;
                    if (manager.useWebSockets)
                    {
                        serverMsg += " (Using WebSockets)";
                    }
                    GUI.Label(new Rect(xpos, ypos, buttonWidth, buttonHeight), serverMsg);
                    ypos += spacing;
                }
                if (manager.IsClientConnected())
                {
                    GUI.Label(new Rect(xpos, ypos, buttonWidth, buttonHeight), "Client: address=" + manager.networkAddress + " port=" + manager.networkPort);
                    ypos += spacing;
                }
            }

            if (manager.IsClientConnected() && !ClientScene.ready)
            {
                if (GUI.Button(new Rect(xpos, ypos, buttonWidth, buttonHeight), "Client Ready"))
                {
                    ClientScene.Ready(manager.client.connection);

                    if (ClientScene.localPlayers.Count == 0)
                    {
                        ClientScene.AddPlayer(0);
                    }
                }
                ypos += spacing;
            }

            if (NetworkServer.active || manager.IsClientConnected())
            {
                if (GUI.Button(new Rect(xpos, ypos, buttonWidth, buttonHeight), "Quit"))
                {
                    manager.StopHost();
                }
                ypos += spacing;
            }
        }
コード例 #11
0
        void OnGUI()
        {
            if (!showGUI)
            {
                return;
            }

            bool noConnection = (manager.client == null || manager.client.connection == null ||
                                 manager.client.connection.connectionId == -1);

            GUILayout.BeginArea(new Rect(10 + offsetX, 40 + offsetY, 215, 9999));
            if (!manager.IsClientConnected() && !NetworkServer.active)
            {
                if (noConnection)
                {
                    // LAN Host
                    if (Application.platform != RuntimePlatform.WebGLPlayer)
                    {
                        if (GUILayout.Button("LAN Host"))
                        {
                            manager.StartHost();
                        }
                    }

                    // LAN Client + IP
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("LAN Client"))
                    {
                        manager.StartClient();
                    }
                    manager.networkAddress = GUILayout.TextField(manager.networkAddress);
                    GUILayout.EndHorizontal();

                    // LAN Server Only
                    if (Application.platform == RuntimePlatform.WebGLPlayer)
                    {
                        // cant be a server in webgl build
                        GUILayout.Box("(  WebGL cannot be server  )");
                    }
                    else
                    {
                        if (GUILayout.Button("LAN Server Only"))
                        {
                            manager.StartServer();
                        }
                    }
                }
                else
                {
                    // Connecting
                    GUILayout.Label("Connecting to " + manager.networkAddress + ":" + manager.networkPort + "..");
                    if (GUILayout.Button("Cancel Connection Attempt"))
                    {
                        manager.StopClient();
                    }
                }
            }
            else
            {
                // server / client status message
                if (NetworkServer.active)
                {
                    string serverMsg = "Server: port=" + manager.networkPort;
                    if (manager.useWebSockets)
                    {
                        serverMsg += " (Using WebSockets)";
                    }

                    GUILayout.Label(serverMsg);
                }
                if (manager.IsClientConnected())
                {
                    GUILayout.Label("Client: address=" + manager.networkAddress + " port=" + manager.networkPort);
                }
            }

            // client ready
            if (manager.IsClientConnected() && !ClientScene.ready)
            {
                if (GUILayout.Button("Client Ready"))
                {
                    ClientScene.Ready(manager.client.connection);

                    if (ClientScene.localPlayers.Count == 0)
                    {
                        ClientScene.AddPlayer(0);
                    }
                }
            }

            // stop
            if (NetworkServer.active || manager.IsClientConnected())
            {
                if (GUILayout.Button("Stop"))
                {
                    manager.StopHost();
                }
            }

            GUILayout.EndArea();
        }
コード例 #12
0
 public void SetupServer()
 {
     /*int port = UpdatePort ();
      * NetworkServer.Listen (port);*/
     nm.StartServer();
 }