Thanks for responding Aren!
I'm still not having luck with calling TNManager.Connect() directly after a TNServerInstance.Start(), so I may be missing something else that's important and that I failed to mention. Here's the component written for this:
using UnityEngine;
using System.Collections;
using System.Net;
using TNet;
public class NetworkManager : MonoBehaviour {
public string lobbyUrl = "<my lobby's public IP address here>";
public int lobbyPort = 5129;
public TNServerInstance.Type lobbyType = TNServerInstance.Type.Tcp;
public int tcpPort = 6127;
void Awake ()
{
TNLobbyClient.onChange += OnListChange;
}
void Start () {
StartServer();
}
/// <summary>
/// Starts a server and registers it to the remote lobby.
/// </summary>
public void StartServer()
{
int udpPort = Random.Range(10000,40000);
// start a server and register it to the remote lobby
Debug.Log("Starting Server...");
bool didServerStart = TNServerInstance.Start(tcpPort, udpPort, null, lobbyType, Tools.ResolveEndPoint(lobbyUrl, lobbyPort));
// connect to the local server that was just started
if(didServerStart)
{
Debug.Log("Server started! Attempting to connect to server");
TNManager.Connect("127.0.0.1", tcpPort);
}
}
private void OnListChange()
{
Debug.Log("Server list change detected.");
}
public void OnNetworkConnect(bool success, string message)
{
Debug.Log("Was connection successful? " + success + " what's the accompanying message? " + message);
}
}
The GameObject hosting this component also has TNTcpLobbyClient and TNManager attached, so it should hit OnNetworkConnect once it connects. OnNetworkConnect doesn't seem to get hit however, according to the attached screenshot of the resulting console log. If it matters, I started the Lobby server with these parameters:
TNServer -name "My Server" -tcpLobby 5129
Am I missing something in this setup that's causing it to not invoke OnNetworkConnect?