Ejemplo n.º 1
0
        private async void HandleGetChannelList(BncsReader dr)
        {
            List<string> channelList = new List<string>();
            string channel;
            do
            {
                channel = dr.ReadCString();
                if (!string.IsNullOrEmpty(channel))
                    channelList.Add(channel);
            } while (!string.IsNullOrEmpty(channel));

            ChannelListEventArgs e = new ChannelListEventArgs(channelList.ToArray());
            ((IChatConnectionEventSource)this).OnChannelListReceived(e);

            if (!_firstChannelList)
            {
                _firstChannelList = true;

                BncsPacket pckJoinChan = CreatePacket(BncsPacketId.JoinChannel);
                if (_settings.Client == ClassicProduct.Diablo2Retail || _settings.Client == ClassicProduct.Diablo2Expansion)
                    pckJoinChan.InsertInt32((int)ChannelJoinFlags.Diablo2FirstJoin);
                else
                    pckJoinChan.InsertInt32((int)ChannelJoinFlags.FirstJoin);

                switch (_settings.Client.ProductCode)
                {
                    case "STAR":
                    case "SEXP":
                    case "W2BN":
                    case "D2DV":
                    case "D2XP":
                    case "JSTR":
                        pckJoinChan.InsertCString(_settings.Client.ProductCode);
                        break;
                    case "WAR3":
                    case "W3XP":
                        pckJoinChan.InsertCString("W3");
                        break;
                }

                await pckJoinChan.SendAsync(_connection);
            }
        }
Ejemplo n.º 2
0
 static void client_ChannelListReceived(object sender, ChannelListEventArgs e)
 {
     _channel = e;
     PrintTidTs(DateTime.Now);
     console.OutputForegroundColor = ConsoleColor.Yellow;
     console.WriteLine("Available channels:");
     console.OutputForegroundColor = ConsoleColor.Cyan;
     foreach (string name in e.Channels)
     {
         console.WriteLine(" - {0}", name);
     }
 }