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...
void OnNetworkConnect(bool success, string message){
TNManager.JoinChannel(1, "Adventuring");
}
void OnNetworkJoinChannel(bool success, string message){
print ("Channel joined "+success);
}
void StartServer(){
// Start this thing. Not sure why
IO_MessageBox.instance.SetMessage("Start server", "Starting server isactive "+TNServerInstance.isActive+" lobby "+lobby.remotePort);
// Tools.ResolveIPs(null);
if(!TNServerInstance.isActive){
TNServerInstance.Start(serverTcpPort, Random.Range(10000, 40000), lobby.remotePort, "server.dat", TNServerInstance.Type.Udp);
}
}
void JoinGame(){
List<ServerList.Entry> list = TNLobbyClient.knownServers.list;
IO_MessageBox.instance.SetMessage("server list", "found this many servers "+list.Count);
if(list.Count > 0){
ServerList.Entry ent = list[0];
IO_MessageBox.instance.SetMessage("Let's Go!", "Joining game ");
TNManager.Connect(ent.internalAddress, ent.internalAddress);
}
}
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?