I myself have found a solution to the problem.
If you want to get id of all players on the server without joining the channel you have to add your own package to TNPacket.cs and TNGameServer.cs.
I add to TNPacket.cs :
public enum Packet
{
Empty,
......,
RequestClients, //my new packet
.....,
}
And add to TNGameServer.cs:
find
case Packet.RequestChannelList: and place here new case
case Packet.RequestClients:
{
BinaryWriter writer = BeginSend(Packet.RequestClients);
int count = mPlayers.size;
writer.Write(count);
for (int i=0; i < mPlayers.size; ++i)
{
writer.Write(mPlayers[i].id);
}
EndSend(true, player);
break;
}
after all, in the script where you want to get the players's id, add these:
float RefreshOffserRate =2.5f; //delay not to send requests all the time
float NextRefreshUpdate = 0.0f;
public System.Collections.Generic.List<int> clients
= new System.Collections.Generic.List<int>();
void Update () {
if (Time.time > NextRefreshUpdate) {
TNManager.client.BeginSend(Packet.RequestClients);
TNManager.client.EndSend();
NextRefreshUpdate = Time.time + RefreshOffserRate;
}
}
void OnNetworkConnect (bool success, string message) {
if (success){
TNManager.client.packetHandlers[(byte)Packet.RequestClients] = OnClientsList;
}
void OnClientsList(Packet response, BinaryReader reader, IPEndPoint source)
{
int count = reader.ReadInt32();
clients.Clear();
for (int i = 0; i < count; ++i)
{
clients.Add(reader.ReadInt32());
}
}
that's all, I hope someone helped