Author Topic: Channel list name - problem  (Read 2000 times)

kreibich

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Channel list name - problem
« on: June 21, 2016, 07:18:01 PM »
Hi,
 I'm working on online game using TNet 3.0.2 and I have a problem with list of channels.

Before player enterst the channel, I need a table with list of channels, which works great, it shows channel ID, number of players, it says if room has password, but i would like to specify some other things like channel name and channel admin name. So I used channel data, but I cannot view data before I enter the channel. I don't want to enter and leave 100 channels just to read a channel name. Is there any simplier way?

Thank you.

Bill.Smock

  • Newbie
  • *
  • Thank You
  • -Given: 6
  • -Receive: 2
  • Posts: 19
    • View Profile
Re: Channel list name - problem
« Reply #1 on: June 22, 2016, 09:19:04 PM »
Set the data when the channel is created:

  1.     void OnJoinChannel(int channelID, bool success, string msg)
  2.     {
  3.         if (!TNManager.isHosting)
  4.             return;
  5.  
  6.         TNManager.SetChannelData("ChannelName", "name of channel");
  7.     }
  8.  

Then, when you populate your table, get the data:

  1.     void Start()
  2.     {
  3.         TNManager.GetChannelList(OnListRefresh);
  4.     }
  5.  
  6.     void OnListRefresh(TNList<Channel.Info> list)
  7. {
  8.    // use list[index].data.GetChild<string>("ChannelName");
  9. }
  10.  

kreibich

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Channel list name - problem
« Reply #2 on: June 26, 2016, 04:17:01 PM »
It works, thanks a lot!