I'm trying to poll the TNet Lobby server for the list of servers, so my players can click one to join.
On my gameobject that controls the main menu, I've assigned the "TNet Network Manager" script and a "TNUdp Lobby Client". In the latter, I set the lobby server to my remote box's hostname (it's a Amazon Micro Win2K12) and made sure Windows Firewall allows the compiled binary (I took the one included with the UnityPackage and did some minor adjustments). Server ports are 31337, 31338 and 31339.
Here's what the current gameobject looks like. Hostname obscured for privacy/security reasons.
When clicking play, this comes out of the console:
[TNet] Local IPs: 1
1: 192.168.0.9 (Primary)
UnityEngine.Debug:Log(Object)
TNManager:Awake() (at Assets/TNet/Client/TNManager.cs:905)
Which I assume means that TNet is awake. Sometimes the UPNP Gateway says "Not found, can't open ports automatically", sometimes it's quiet, sometimes it reports back the gateway IP. Dunno if that's a issue with a stuck port, or what. Now, in the code...
void Start() {
TNManager.client.packetHandlers[(byte)Packet.ResponseChannelList] = OnChannelList;
refreshHostList();
}
<....>
void refreshHostList(){
isBusy = true;
TNManager.client.BeginSend(Packet.RequestChannelList);
TNManager.client.EndSend();
}
void OnChannelList (Packet response, BinaryReader reader, IPEndPoint source){
Debug.Log("If you can see this, we have channels. Maybe.");
// The first integer represents the number of entries to follow
int channels = reader.ReadInt32();
// Read all incoming channel data
for (int i = 0; i < channels; ++i)
{
int id = reader.ReadInt32();
int players = reader.ReadUInt16();
int limit = reader.ReadUInt16();
bool pass = reader.ReadBoolean();
bool persistent = reader.ReadBoolean();
string level = reader.ReadString();
string data = reader.ReadString();
// TODO: Do something with this data here
}
isBusy = false;
}
The OnChannelList code was pulled from
here with a slight edit to see if TNet will actually get the stuff. However, it never says the Debug output.
I'm baffled at what I need to do. Do I need to use TNManager.Start(port) to start listening for info between the server and client? Or what am I missing? Note that a good chunk of the code is cut out because I'm not going to paste the entire script.
PRE-POST EDIT: Okay, so I switched to TCP Lobby Client and it seems to be better. However, on the server, I'm getting things like:
<my public dev box IP>:<randomport> has connected.
<my public dev box IP>:<randomport> has timed out.
<my public dev box IP>:<randomport> has disconnected.
<my public dev box IP>:<old port plus 2> has connected.
<.....>
At least this output is better than nothing, that's for sure.
Can anyone provide pointers on what could possibly be going wrong?