Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: Shifty Geezer on June 21, 2015, 01:27:55 PM

Title: Server sometimes not starting
Post by: Shifty Geezer on June 21, 2015, 01:27:55 PM
I create a server when a button is pressed with code hacked from the example menu. The intention at the moment is just to create and join the first game on the network, transparent to the user. Although it works, it's not completely stable. Sometimes on PC I get an odd warning along the lines of "host not known see //whatismyipaddress." On Android, I've had the same code work creating a networked game and also fail to start. I use TNet's lobby system with this relevant code...

  1. void OnNetworkConnect(bool success, string message){
  2.         TNManager.JoinChannel(1, "Adventuring");
  3. }
  4.  
  5. void OnNetworkJoinChannel(bool success, string message){
  6.         print ("Channel joined "+success);             
  7. }
  8.  
  9. void StartServer(){
  10.         // Start this thing. Not sure why
  11.         IO_MessageBox.instance.SetMessage("Start server", "Starting server isactive "+TNServerInstance.isActive+" lobby "+lobby.remotePort);
  12. //              Tools.ResolveIPs(null);
  13.  
  14.         if(!TNServerInstance.isActive){
  15.                 TNServerInstance.Start(serverTcpPort, Random.Range(10000, 40000), lobby.remotePort, "server.dat", TNServerInstance.Type.Udp);
  16.         }
  17. }
  18.        
  19. void JoinGame(){
  20.         List<ServerList.Entry> list = TNLobbyClient.knownServers.list;
  21.         IO_MessageBox.instance.SetMessage("server list", "found this many servers  "+list.Count);
  22.         if(list.Count > 0){
  23.                 ServerList.Entry ent = list[0];
  24.                 IO_MessageBox.instance.SetMessage("Let's Go!", "Joining game ");
  25.                 TNManager.Connect(ent.internalAddress, ent.internalAddress);
  26.         }
  27. }      
I'm having trouble reproducing the fault to track down the issue. Could it be the lobby server isn't ready at the point I'm testing it? A result of enabling/disabling the Tools.ResolveIps()? Is there a correct way to handle this?
Title: Re: Server sometimes not starting
Post by: ArenMook on June 21, 2015, 09:42:00 PM
ResolveIPs() takes a delegate that will be called when the IPs actually get resolved. You aren't passing anything, meaning the call will finish at some point in the future, but you aren't waiting on it to finish.