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;
}