//=========================================================================
// Start()
// Initialization event for monobehaviors. Called after Awake()
//=========================================================================
void Start ()
{
//TNServerInstance.Stop(); //Maybe this will clean up the server instance?
if (Application.isPlaying)
{
// Start resolving IPs
Tools.ResolveIPs(null);
// We don't want mobile devices to dim their screen and go to sleep while the app is running
Screen.sleepTimeout = SleepTimeout.NeverSleep;
// Make it possible to use UDP using a random port
TNManager.StartUDP(Random.Range(10000, 50000));
Debug.Log("Server instance active " + TNServerInstance.isActive);
if (TNServerInstance.isActive)
{
//connect here
Debug.Log("Started with instance already active. Join here!");
//List of discovered servers
List<ServerList.Entry> list = TNLobbyClient.knownServers.list;
Debug.Log("Known servers " + list.Count);
if (list.Count > 0)
{
TNManager.Connect(list[0].internalAddress, list[0].internalAddress);
}
}
else
{
StartServer();
}
}
}