Author Topic: CloseChannel bug  (Read 2916 times)

tonyM

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 24
    • View Profile
CloseChannel bug
« on: June 07, 2013, 05:00:20 AM »
Hi,

I am locking a channel (1) when a particular game has started but this is still visible when I query the channel list (2).

(1)
  1. TNManager.client.BeginSend(Packet.RequestCloseChannel);
  2. TNManager.client.EndSend();

(2)
  1. TNManager.client.BeginSend(Packet.RequestChannelList);
  2. TNManager.client.EndSend();

Trying to join the channel returns an error as expected. "The requested channel is closed" but shouldn't the request return open channels only?

Thanks

tonyM

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: CloseChannel bug
« Reply #1 on: June 10, 2013, 03:04:25 AM »
Any update on this please?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: CloseChannel bug
« Reply #2 on: June 10, 2013, 03:10:50 AM »
The channel list returns all active channels, whether they have been closed or not. It's up to you to filter them on the client side. I advise using the channel data field to pass useful information. That's what I do in Starlink to pass the map name and current progress information, for example.

tonyM

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: CloseChannel bug
« Reply #3 on: June 10, 2013, 03:12:25 AM »
Ok thanks. I think the documentation says it will give you the open channels only.

I can use the channel data though!


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: CloseChannel bug
« Reply #4 on: June 10, 2013, 03:13:17 AM »
Hmm... you're right there -- it does say that it should only list open channels. Typo in the comment I suppose.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: CloseChannel bug
« Reply #5 on: June 10, 2013, 03:15:30 AM »
You can replace the RequestChannelList handling with this:
  1.                         case Packet.RequestChannelList:
  2.                         {
  3.                                 BinaryWriter writer = BeginSend(Packet.ResponseChannelList);
  4.  
  5.                                 int count = 0;
  6.                                 for (int i = 0; i < mChannels.size; ++i)
  7.                                         if (!mChannels[i].closed) ++count;
  8.  
  9.                                 writer.Write(count);
  10.  
  11.                                 for (int i = 0; i < mChannels.size; ++i)
  12.                                 {
  13.                                         Channel ch = mChannels[i];
  14.  
  15.                                         if (!ch.closed)
  16.                                         {
  17.                                                 writer.Write(ch.id);
  18.                                                 writer.Write((ushort)ch.players.size);
  19.                                                 writer.Write(ch.playerLimit);
  20.                                                 writer.Write(!string.IsNullOrEmpty(ch.password));
  21.                                                 writer.Write(ch.persistent);
  22.                                                 writer.Write(ch.level);
  23.                                                 writer.Write(ch.data);
  24.                                         }
  25.                                 }
  26.                                 EndSend(true, player);
  27.                                 break;
  28.                         }