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); } }
IEnumerator UpdateHostsList() { while (refreshHostList) { MasterServerUtils.RequestHostList(); hosts = MasterServerUtils.ListHost(); hostsUpdated = true; yield return(new WaitForSeconds(refreshHostListFrequency)); } }
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); } }
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); } } }
void Awake() { //Request the list as soon we're able to, so it's ready to display MasterServerUtils.RequestHostList(); }
//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); }