コード例 #1
0
 //Iniciar Servidor******************************************
 public void RunServer()
 {
     if (!NetworkClient.isConnected && !NetworkServer.active)
     {
         if (!NetworkClient.active)
         {
             manager.StartServer();
             networkDiscovery.AdvertiseServer();
         }
     }
     AddressData();
 }
コード例 #2
0
ファイル: LobbyMenu.cs プロジェクト: jorgelosada10/TanksLAN
    public void RunServer()
    {
        if (!NetworkClient.isConnected && !NetworkServer.active)
        {
            if (!NetworkClient.active)
            {
                discoveredServers.Clear();
                m_TanksNetwork.StartServer();
                networkDiscovery.AdvertiseServer();
            }
        }

        AddressData();
    }
コード例 #3
0
 public void StartServer()
 {
     if (NetworkClient.isConnected == false &&
         NetworkServer.active == false &&
         NetworkClient.active == false)
     {
         ReinitializeDiscovery();
         NetworkManager.singleton.StartServer();
         networkDiscovery.AdvertiseServer();
     }
     else
     {
         LogConsoleWarning("Trying to start a new server but this client is already connected");
     }
 }
コード例 #4
0
    void DrawGUI()
    {
        GUILayout.BeginHorizontal();

        var options = new GUILayoutOption[] { GUILayout.Height(80), GUILayout.Width(120) };

        if (GUILayout.Button("Find Servers", options))
        {
            discoveredServers.Clear();
            networkDiscovery.StartDiscovery();
        }

        // LAN Host
        if (GUILayout.Button("Start Host", options))
        {
            discoveredServers.Clear();
            NetworkManager.singleton.StartHost();
            networkDiscovery.AdvertiseServer();
        }

        // Dedicated server
        if (GUILayout.Button("Start Server", options))
        {
            discoveredServers.Clear();
            NetworkManager.singleton.StartServer();

            networkDiscovery.AdvertiseServer();
        }

        GUILayout.EndHorizontal();

        // show list of found server

        GUILayout.Label($"Discovered Servers [{discoveredServers.Count}]:");

        // servers
        scrollViewPos = GUILayout.BeginScrollView(scrollViewPos);

        foreach (ServerResponse info in discoveredServers.Values)
        {
            if (GUILayout.Button(info.EndPoint.Address.ToString(), options))
            {
                Connect(info);
            }
        }

        GUILayout.EndScrollView();
    }
コード例 #5
0
    void Start()
    {
        searchPanel.SetActive(false);
        gameConfiguration = FindObjectOfType <GameConfiguration>();
        searchGlass       = FindObjectOfType <SearchGlass>();

        StartCoroutine(HidePanel());

        IEnumerator HidePanel()
        {
            yield return(new WaitForSeconds(1f));

            switch (gameConfiguration.role)
            {
            case 0:
                NetworkManager.singleton.StartHost();
                networkDiscovery.AdvertiseServer();

                loadingPanel.SetActive(false);

                break;

            case 1:
                searchPanel.SetActive(true);
                loadingPanel.SetActive(false);
                networkDiscovery.StartDiscovery();
                StartCoroutine(UpdateAndAttemptConnection());

                break;
            }
        }
    }
コード例 #6
0
 public void StartHost()
 {
     discoveredServers.Clear();
     NetworkManager.singleton.StartHost();
     networkDiscovery.AdvertiseServer();
     isPlaying = true;
     GameManager.Instance.LoadScene(GameManager.sceneName, false);
 }
コード例 #7
0
    //When start host button is clicked
    public void StartHost()
    {
        discoveredServers.Clear(); //clear existing servers

        Debug.Log("Starting as host...");
        NetworkManager.singleton.StartHost(); //start a new network manager host
        networkDiscovery.AdvertiseServer();   //advertises this new host in the list

        Debug.Log("Host server advertised");

        Debug.Log("Show lobby");
    }
コード例 #8
0
 void Start()
 {
     if (OnStartAction == OnStartPlayAction.CREATE_AND_JOIN)
     {
         gameNetwork.StartHost();
         networkDiscovery.AdvertiseServer();
     }
     else if (OnStartAction == OnStartPlayAction.ONLY_JOIN)
     {
         gameNetwork.StartClient();
     }
 }
コード例 #9
0
        // -------------------------------------------

        /*
         * OnBasicSystemEvent
         */
        private void OnBasicSystemEvent(string _nameEvent, object[] _list)
        {
            if (_nameEvent == EVENT_MIRRORDISCOVERYCONTROLLER_TIMEOUT_DISCOVERY)
            {
                if (m_discovering)
                {
                    m_discovering = false;
                    m_networkDiscovery.StopDiscovery();

                    CommunicationsController.Instance.IsServer = true;
                    StartHost();
                    m_networkDiscovery.AdvertiseServer();
                    NetworkEventController.Instance.DispatchLocalEvent(NetworkEventController.EVENT_COMMUNICATIONSCONTROLLER_REGISTER_ALL_NETWORK_PREFABS);
                    BasicSystemEventController.Instance.DispatchBasicSystemEvent(CommunicationsController.EVENT_COMMSCONTROLLER_SET_UP_IS_SERVER);

                    Debug.LogError("%%%%%%%%%% MirrorDiscoveryController::STARTED AS A SERVER (MIRROR).");
                }
            }
        }
コード例 #10
0
ファイル: NetworkSystem.cs プロジェクト: songying/mrpp
 public void startHost()
 {
     discoveredServers.Clear();
     _manager.StartHost();
     _discovery.AdvertiseServer();
 }
コード例 #11
0
 public void AdvertiseServers()
 {
     discoveredServers.Clear();
     networkDiscovery.AdvertiseServer();
 }