This Is Function for Hosting Server Its Called On Button Press The Script Is Attached To Empty Game Object With TN Manager, TN Object and TN UDPLobbyClient Script Attached.
public void OnCreateServer()
{
//Stating Ports For tcp Upd and LAN
int udpPort = Random.Range(10000, 40000);
TNLobbyClient lobby = GetComponent<TNLobbyClient>();
if (lobby == null)
{
//TNServerInstance.Start(tcpPort,udpPort,lobbyPort,"server.dat");
TNServerInstance.Start(serverTcpPort, udpPort, "server.dat");
}
else
{
//Hosting Server
mMessage = "Server started";
TNServerInstance.Type type = (lobby is TNUdpLobbyClient) ? TNServerInstance.Type.Udp : TNServerInstance.Type.Tcp;
TNServerInstance.Start(serverTcpPort, udpPort, lobby.remotePort, "server.dat", type);
}
TNManager.Connect (Tools.localAddress.ToString());
}
This Function is Called On a In Game Button
public void OnResetTap()
{
BackToMenu = true;
TNManager.Disconnect();
}
void OnNetworkLeaveChannel ()
{
TNManager.LoadLevel("GameMenu");
}
This is Called On GameMenu
void Start()
{
if(MultiplayerResetScript.BackToMenu == true)
{
TNServerInstance.Stop("server.dat");
MultiplayerResetScript.BackToMenu = false;
}
}
After This if I Try Re-Hosting Server or Try To Join to Already Hosted Server I'm unable to do so. Sorry for Long Post.