Пример #1
0
    public void StartServer()
    {
        //Determine if we should use network address translation
        //Essentially, YES if server is behind a router
        //             NO is server has a public IP
        if (lanOnly == true)
        {
            useNAT = false;
        }
        else
        {
            useNAT = !Network.HavePublicAddress();
        }

        //Start a simple server and add it to the master server list.
        //This will allow other players to locate it.
        NetworkConnectionError state = Network.InitializeServer(playerCount, serverPort, useNAT);

        if (state == NetworkConnectionError.NoError)
        {
            MasterServerUtils.RegisterWithMasterServer("Unity CCG Master", "This is a comment about TestServer");
        }
        else
        {
            Log("Server: Couldn't initalize server! " + state);
        }
    }
Пример #2
0
    IEnumerator UpdateHostsList()
    {
        while (refreshHostList)
        {
            MasterServerUtils.RequestHostList();
            hosts        = MasterServerUtils.ListHost();
            hostsUpdated = true;

            yield return(new WaitForSeconds(refreshHostListFrequency));
        }
    }
Пример #3
0
    public void StartServer()
    {
        NetworkConnectionError state = Network.InitializeServer(playerCount, serverPort, useNAT);

        if (state == NetworkConnectionError.NoError)
        {
            MasterServerUtils.RegisterWithMasterServer("Testing test game", "Heres an obligatory comment");
            serverStarted = true;
        }
        else
        {
            Debug.Log("server failed to initalize -> " + state);
        }
    }
Пример #4
0
 public void StartServer()
 {
     if (!serverStarted)
     {
         NetworkConnectionError state = Network.InitializeServer(playerCount, serverPort, useNAT);
         if (state == NetworkConnectionError.NoError)
         {
             MasterServerUtils.RegisterWithMasterServer("Unity UI CCG", "This is a comment about TestServer");
             serverStarted = true;
         }
         else
         {
             Debug.Log("Couldn't initialize server! " + state);
         }
     }
 }
Пример #5
0
 void Awake()
 {
     //Request the list as soon we're able to, so it's ready to display
     MasterServerUtils.RequestHostList();
 }
Пример #6
0
 //All monobehaviours will have this called when we can't connect to the master server
 // duplicating this function in multiple monobehaviours is fine, it will just duplicate
 // any response to the error (printing messages, trying a new master server, etc.).
 void OnFailedToConnectToMasterServer(NetworkConnectionError info)
 {
     MasterServerUtils.OnFailedToConnectToMasterServer(info);
 }