Exemplo n.º 1
0
 public static List <HostData> ListHost()
 {
     ConfigureMasterServer();
     HostData[] hostData = MasterServer.PollHostList();
     MasterServer.ClearHostList();
     return(hostData.ToList());
 }
Exemplo n.º 2
0
    public void RefreshHostList()
    {
        Debug.Log("Refreshing host list");
        MasterServer.ClearHostList();

        MasterServer.RequestHostList(typeName);
    }
Exemplo n.º 3
0
    private void OnClick()
    {
        Debug.Log("PlayButtonScript OnClick");

        MasterServer.ClearHostList();
        MasterServer.RequestHostList(GameType);
    }
Exemplo n.º 4
0
    public IEnumerator RefreshHostList()
    {
        //fill hostData informations about servers with was found
        MasterServer.ClearHostList();
        Debug.Log("Refreshing...");
        MasterServer.RequestHostList(registeredGameName);

        float timeStarted = Time.time;
        float timeEnd     = Time.time + refreshLength;

        while (Time.time < timeEnd)
        {
            hostData = MasterServer.PollHostList();
            yield return(new WaitForEndOfFrame());
        }

        if (hostData == null || hostData.Length == 0)
        {
            Debug.Log("No servers found");
        }
        else
        {
            Debug.Log(hostData.Length + " servers has been found");
        }
    }
Exemplo n.º 5
0
    void OnMasterServerEvent(MasterServerEvent msEvent)
    {
        Debug.Log("MasterServerEvent");


        // Si el servidor se registra bien... cargamos la escena de looby
        if (msEvent == MasterServerEvent.RegistrationSucceeded)
        {
            LaunchServer();
        }
        else if (msEvent == MasterServerEvent.HostListReceived)
        {
            hostList = MasterServer.PollHostList();

            if (hostList.Length > 0)
            {
                for (int i = 0; i < hostList.Length; i++)
                {
                    if (hostList[i].connectedPlayers < hostList[i].playerLimit)
                    {
                        JoinServer(hostList[i]);

                        return;
                    }
                }
            }

            Debug.Log("No se han encontrado partidas");
            panelNoPartidasEncontradas.SetActive(true);
            panelSpinner.SetActive(false);

            MasterServer.ClearHostList();
        }
    }
 void refreshHostList()
 {
     // let the user know we are awaiting results from the master server
     loading = true;
     MasterServer.ClearHostList();
     MasterServer.RequestHostList("NewAtlantis");
 }
        private IEnumerator FetchHostsFromMasterServer()
        {
            MasterServer.ClearHostList();
            MasterServer.RequestHostList(gameTypeName);
            float timeOutTime = Time.time + timeOut;

            while (Time.time < timeOutTime)
            {
                availableHosts = MasterServer.PollHostList();
                if (availableHosts.Length > 0)
                {
                    if (OnHostListFetchCompleted != null)
                    {
                        OnHostListFetchCompleted(true, availableHosts);
                    }

                    yield break;
                }

                yield return(new WaitForSeconds(1f));
            }

            Debug.Log("Timed out waiting for host list");
            if (OnHostListFetchCompleted != null)
            {
                OnHostListFetchCompleted(false, null);
            }
        }
Exemplo n.º 8
0
    public void RefreshHostList()
    {
        /* */
        this.internetTapQueue.QueueIfOnline(() => {
            // Get servers from the masterserver (online)
            Debug.Log("MasterServer.ClearHostList()");
            MasterServer.ClearHostList();
            Debug.Log("MasterServer.RequestHostList");
            MasterServer.RequestHostList(this.uniqueGameName);
        });
        /* */

        this.serverList.Clear();
        this.lanManager.ClearServerList();
        // We cleared the lists so fire the event
        this.OnServerListUpdated(this.CombinedServerListArray);         // Fire Event

        // Start finding servers that are LAN
        this.lanManager.StartDiscovery();


        // Start the update loop
        this.refreshing = true;
        this.timeSinceRefreshRequest = 0;
    }
Exemplo n.º 9
0
 void refreshHostList()
 {
     // let the user know we are awaiting results from the master server
     loading = true;
     MasterServer.ClearHostList();
     MasterServer.RequestHostList("GameTypeNameHere");
 }
    void Update()
    {
        if (!ip.Equals(NetworkManager.NetworkInstance.MASTER.ip))
        {
            ip = NetworkManager.NetworkInstance.MASTER.ip;
            MasterServer.ipAddress = ip;
            MasterServer.ClearHostList();
            MasterServer.RequestHostList("NavySim");
        }
        if (Application.loadedLevelName.Equals("Login"))
        {
            if (MasterServer.PollHostList().Length != 0)
            {
                hostData = MasterServer.PollHostList();
                int i = 0;
                names = new string[hostData.Length];
                while (i < hostData.Length)
                {
                    names [i] = hostData [i].gameName;

                    i++;
                }
                MasterServer.ClearHostList();
                MasterServer.RequestHostList("NavySim");
            }
        }
    }
Exemplo n.º 11
0
 void Start()
 {
     Screen.sleepTimeout = SleepTimeout.NeverSleep;
     MasterServer.ClearHostList();
     MasterServer.RequestHostList("yourFVName");
     hostData = MasterServer.PollHostList();
 }
Exemplo n.º 12
0
    // Use this for initialization
    void Start()
    {
        nvs = GameObject.FindWithTag("NetObj").GetComponent("networkVariables") as networkVariables;
        // get server version
        serverVersion = nvs.serverVersion;
        // get NATmode
        NATmode = nvs.NATmode;

        // sudo make me a camera
        nvs.myCam = new GameObject("theCamera").AddComponent <Camera>() as Camera;
        nvs.myCam.gameObject.AddComponent <AudioListener>();
        nvs.myCam.gameObject.SetActive(false);          // disable it until we have joined a game

        // get them servers
        MasterServer.ClearHostList();
        MasterServer.RequestHostList(serverVersion);

        // check if we don't have a valid NATmode
        if (NATmode == -1)
        {
            // test the current setup rather than poll for the result
            connectionTestResult = Network.TestConnection(true);
            doneTesting          = false;
        }
        else
        {
            SetMessage();
            doneTesting = true;
        }
    }
Exemplo n.º 13
0
    /*void SpawnPlayer()	{
     *      // Spawning the player. By using Network.Instantiate instead of just Instantiate, everyone on the server will have the player object instantiated (Though control should be reserved only to the owner of the NetworkView)
     *      int randomSpawn = Random.Range(0, spawnZones.Length-1);	// We're choosing random spawn points from an array just for convenience here - you can handle this how you like, just keep in mind: Network.Instantiate creates the object on everyone's end
     *      GameObject networkPlayer = Network.Instantiate(playerObject, spawnZones[randomSpawn].transform.position, Quaternion.identity, 0) as GameObject;
     *      networkPlayer.networkView.RPC("SetUsername", RPCMode.AllBuffered, advancedSettings.username);
     * }*/

    public void RefreshHostList()
    {
        // When invoked, clear out the host list of previous data, and get a fresh list
        MasterServer.ClearHostList();
        MasterServer.RequestHostList(advancedSettings.gameName);
        if (hostList != null)
        {
            Debug.Log("Hostlist != null, length = " + hostList.Length);
            // If there is data in the hostList, display each server as a button
            //First, destroy the current buttons in the list
            DestroyCurrentButtons();
            for (int i = 0; i < hostList.Length; i++)
            {
                Button serverButton = Instantiate(buttonPrefab) as Button;
                serverButton.GetComponentInChildren <Text>().text = (hostList[i].gameName + " | " + hostList[i].connectedPlayers + "/" + hostList[i].playerLimit + " players");
                serverButton.transform.parent = buttonListHolder;
                serverButton.GetComponent <ServerButtonHandler>().serverNumber = i;
                serverButton.transform.localPosition = new Vector3(-137, -5 - (30 * i), 0);                     //X should actually be 5, but there is a parenting issue (Unity 4.6 is still beta, after all)
            }
        }
        else
        {
            Debug.Log("Hostlist = null");
        }
    }
Exemplo n.º 14
0
 private void hostListReceived()
 {
     log("Host list received");
     hosts = MasterServer.PollHostList();
     MasterServer.ClearHostList();
     updated = true;
 }
Exemplo n.º 15
0
 void Awake()
 {
     MasterServer.ipAddress = m_masterServerIp;
     MasterServer.port      = 23466;
     MasterServer.ClearHostList();
     MasterServer.RequestHostList("SpellGame");
 }
 // Update is called once per frame
 void Update()
 {
     if (connectionState == ConnectionState.Looking)
     {
         if (MasterServer.PollHostList().Length != 0)
         {
             HostData[] hostData = MasterServer.PollHostList();
             // connectStatus = "" + hostData.Length + " hosts found";
             foreach (var server in hostData)
             {
                 if (isGameRandom == true)
                 {
                     Network.Connect(server);
                     connectionState = ConnectionState.Connecting;
                 }
                 else if (server.gameName == gameName)
                 {
                     // Game Found
                     // Attempt to connect to server
                     Network.Connect(server);
                     connectionState = ConnectionState.Connecting;
                 }
             }
             MasterServer.ClearHostList();
         }
     }
 }
Exemplo n.º 17
0
    void Update()
    {
        if (Network.peerType == NetworkPeerType.Disconnected)
        {
            LogText.AddLog("斷線中");
            ConnectServer();
        }
        if (Network.peerType == NetworkPeerType.Client)
        {
            LogText.AddLog("與SERVER保持連線中1");
        }
        if (Network.peerType == NetworkPeerType.Connecting)
        {
            LogText.AddLog("與SERVER保持連線中2");
        }

        LogText.AddLog("touchCount:(" + Input.touchCount + ")");

        if (Input.touchCount == 1)
        {
            onConnect = false;
            ConnectServer();
        }

        if (Input.touchCount == 2)
        {
            MasterServer.ClearHostList();
            MasterServer.RequestHostList("CardBoard");
        }
    }
Exemplo n.º 18
0
 void UpdateServerList()
 {
     header  = "@spinner/Refreshing..";
     timeout = 7;
     MasterServer.ClearHostList();
     MasterServer.RequestHostList("sanicball-unofficial");
 }
Exemplo n.º 19
0
    public void showServerBrowser()
    {
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Refresh"))
        {
            MasterServer.ClearHostList();
            MasterServer.RequestHostList("MonkeyMadness");
        }

        if (GUILayout.Button("Back"))
        {
            CurrentMenu = "Main";
        }

        GUILayout.EndHorizontal();


        hostData = MasterServer.PollHostList();

        if (hostData.Length >= 1)
        {
            for (int t = 0; t < hostData.Length; t++)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Join"))
                {
                    Network.Connect(hostData[t]);
                    CurrentMenu = "Lobby";
                }
                GUILayout.Label("Players: " + hostData[t].connectedPlayers + "/" + hostData[t].playerLimit + "   Password: " + hostData[t].passwordProtected);
                GUILayout.EndHorizontal();
            }
        }
    }
Exemplo n.º 20
0
 public void QuitNetwork()
 {
     //Debug.Log("QuitNetwork");
     MasterServer.ClearHostList();
     MasterServer.UnregisterHost();
     Shutdown();
     Destroy(gameObject);
 }
Exemplo n.º 21
0
    //===========

    void Awake()
    {
        chatSys = GetComponent <ChatSystem>();
        // On Awake, we want to ensure the master server is empty, and a placeholder username is chosen
        MasterServer.ClearHostList();
        testMessage.text = "Testing network connection capabilities.";
//		username = "******"+Random.Range(0,99).ToString();	// We're randomizing a digit at the end, just to give some variety
    }
 public void JoinRandomGame(string playerName)
 {
     connectionState = ConnectionState.Connecting;
     this.playerName = playerName;
     MasterServer.ClearHostList();
     MasterServer.RequestHostList(masterServerGameType);
     isGameRandom    = true;
     connectionState = ConnectionState.Looking;
 }
Exemplo n.º 23
0
 private void OnMasterServerEvent(MasterServerEvent msEvent)
 {
     if (msEvent == MasterServerEvent.HostListReceived)
     {
         HostData[] hostDatas = MasterServer.PollHostList();
         MasterServer.ClearHostList();
         UpdateGamesList(hostDatas);
     }
 }
Exemplo n.º 24
0
    //public static bool IsConnected
    //{
    //    get
    //    {
    //        return Network.isClient || Network.isServer;
    //    }
    //}

    //void ONGui(){


    //        if (GUILayout.Button("refresh hosts"))
    //            MasterServer.RequestHostList(GamePresets.serverName);
    //        if (hostList != null)
    //        {
    //            for (int i = 0; i < hostList.Length; i++)
    //            {
    //                if (GUILayout.Button(hostList[i].gameName))
    //                    Network.Connect(hostList[i]);
    //            }
    //        }

    //}


    public void OnGetHostList()
    {
        MasterServer.ClearHostList();
        MasterServer.RequestHostList(GamePresets.TYPE_NAME);
        if (hostList != null)
        {
            displayGui = true;
        }
    }
Exemplo n.º 25
0
            void DisconnectedGUI()
            {
                //Start new server
                if (GUI.Button(new Rect(10, 10, 90, 30), "Start Server"))
                {
                    Network.InitializeServer(maxPlayers, serverPort, !Network.HavePublicAddress());
                    MasterServer.updateRate = 3;
                    MasterServer.RegisterHost(gameName, "stuff", "profas chat test");
                    subGUIDelegate = this.connectedGUI;
                }

                //Refresh hosts
                if (GUI.Button(new Rect(10, 40, 210, 30), "Refresh Available Servers") ||
                    Time.realtimeSinceStartup > lastHostListRequest + hostListRefreshTimeout)
                {
                    MasterServer.ClearHostList();
                    MasterServer.RequestHostList(gameName);
                    lastHostListRequest = Time.realtimeSinceStartup;
                    Debug.Log("Refresh Click");
                }

                if (GUI.Button(new Rect(10, 70, 210, 30), "Main Menu"))
                {
                    Network.Disconnect();
                    MasterServer.UnregisterHost();
                    guiDone();
                    //Stop();
                    //Application.LoadLevel("ServerChoose");
                }

                HostData [] hostData = MasterServer.PollHostList();
                int         count    = 0;

                foreach (HostData data in hostData)
                {
                    //Do not display NAT enabled games if we cannot do NAT punchthrough
                    if (!(filterNATHosts && data.useNat))
                    {
                        string name = System.String.Format("{0} {1}/{2}",
                                                           data.gameName, data.connectedPlayers, data.playerLimit);
                        string hostInfo = "[";
                        foreach (string host in data.ip)
                        {
                            hostInfo += (host + ":" + data.port + " ");
                        }

                        hostInfo += "]";

                        if (GUI.Button(new Rect(20, (count * 50) + 100, 400, 40), hostInfo))
                        {
                            //Enable NAT functionality based on what the hosts are configured to do
                            Network.Connect(data);
                        }
                    }
                }
            }
 void Awake()
 {
     if (HostInstance == null)
     {
         HostInstance = this;
     }
     MasterServer.ipAddress = ip;
     MasterServer.ClearHostList();
     MasterServer.RequestHostList("NavySim");
 }
Exemplo n.º 27
0
    void Awake()
    {
        if (!gameObject.GetComponent <NetworkView> ())
        {
            gameObject.AddComponent <NetworkView>();
        }

        MasterServer.ClearHostList();
        MasterServer.RequestHostList("CardBoard");
    }
Exemplo n.º 28
0
            public void RefreshServersList()
            {
//				MasterServer.ipAddress = masterServerIP;
//				MasterServer.port = 23466;
//				UnityEngine.Network.natFacilitatorIP = masterServerIP;
//				UnityEngine.Network.natFacilitatorPort = 50005;
                MasterServer.ClearHostList();
                hosts = new List <HostData>();
                MasterServer.RequestHostList(gameIdentifier);
            }
Exemplo n.º 29
0
 public void getServerList()
 {
     MasterServer.ClearHostList();
     MasterServer.RequestHostList("WeatherTacticsEditor");
     foreach (Transform child in m_ServerListPanel.transform)
     {
         GameObject.Destroy(child.gameObject);
     }
     m_bWaitingForServerList = true;
 }
    public void JoinGame(string gameName, string playerName)
    {
        connectionState = ConnectionState.Connecting;
        this.gameName   = gameName;
        this.playerName = playerName;
        MasterServer.ClearHostList();
        MasterServer.RequestHostList(masterServerGameType);

        connectionState = ConnectionState.Looking;
    }