Author Topic: Changing Channel gameName after creation from Host  (Read 1710 times)

BigHandInSky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Changing Channel gameName after creation from Host
« on: July 25, 2016, 05:03:40 AM »
Hello all,

I've been looking through the documentation and this forum for an answer to the following question:

How do I change a Channel's gameName after I create it, such that when I get Channel.Info.gameName, that will have changed accordingly?
Or should I look to changing the Channel's data?

For reference:
We have a game that can be connected to from a server browser, and to stop people joining mid-game I'm setting up the browser such that when the Host starts a game, they change the channel name to "[IN PROGRESS]" + sessionScript.gameName, so when the channel is fetched by the browser it displays the Channel.Info.gameName string, checks for the prefix, then disables the interactable of that browser entry if it is there.

Thanks in advance for any help.

BigHandInSky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Changing Channel gameName after creation from Host
« Reply #1 on: July 25, 2016, 06:39:42 AM »
Update: Made a workaround for this by using the Channel Data:

When the host starts I add a new snippet to the Channel's data:
  1. if (NetworkGameSettings.Instance.SelectedGameType == NetworkGameSettings.GameType.Internet)
  2. {
  3.     TNManager.SetChannelData("inProgress", true);
  4. }

Then given some time spent getting errors from the data not existing until the host starts, I use this to check for whether that snippet exists during our loop through the discovered channels:
  1. foreach (Channel.Info info in channelList)
  2. {
  3.     /* ... */
  4.                
  5.     if (info.data != null)
  6.     {
  7.         if (info.data.Get("inProgress") != null)
  8.         {
  9.             data.GameName = Constants.SERV_IN_PROGRESS + info.gameName;
  10.         }
  11.     }
  12.  
  13.     /* ... */
  14. }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing Channel gameName after creation from Host
« Reply #2 on: July 26, 2016, 10:39:53 PM »
I advise closing the channel instead of changing its name. You can close the channel by doing TNManager.SetPlayerLimit(channel, 0). This means that no one else will be able to join, but you can always change the limit again afterwards to open it.

There is no such thing as "gameName" in channels.