Exemplo n.º 1
0
        private void LoadFavourites()
        {
            List <byte> list = new List <byte>();

            try { list.AddRange(File.ReadAllBytes(Settings.DataPath + "favourites.dat")); }
            catch { }

            if (list.Count > 0)
            {
                UdpPacketReader buf = new UdpPacketReader(list.ToArray());
                list.Clear();
                list = null;

                while (buf.Remaining() > 0)
                {
                    FavouritesListItem item = new FavouritesListItem();
                    item.AutoJoin = buf.ReadByte() == 1;
                    item.IP       = buf.ReadIP();
                    item.Port     = buf.ReadUInt16();
                    item.Name     = buf.ReadString();
                    item.Topic    = buf.ReadString();
                    item.Password = buf.ReadString();
                    this.favs.Add(item);
                    ChannelListViewItem vitem = new ChannelListViewItem(null, 0);
                    this.gfx.RenderChannelListItem(vitem, item);
                    this.g_favs.Add(vitem);
                    this.channelListView2.Items.Add(vitem);
                }

                buf = null;
            }
        }
Exemplo n.º 2
0
        public ChannelListItem(IPEndPoint ep, UdpPacketReader packet)
        {
            this.IP    = ep.Address;
            this.Port  = packet.ReadUInt16();
            this.Users = packet.ReadUInt16();
            this.Name  = packet.ReadString();
            StringBuilder sb = new StringBuilder();
            int           i2;

            foreach (char c in this.Name.ToUpper().ToCharArray())
            {
                i2 = (int)c;

                if ((i2 >= 65 && i2 <= 90) || (i2 >= 48 && i2 <= 57))
                {
                    sb.Append(c);
                }
            }

            this.StrippedName  = sb.ToString();
            this.Topic         = packet.ReadString();
            this.StrippedTopic = Helpers.StripColors(Helpers.FormatAresColorCodes(this.Topic)).ToUpper();
            this.Lang          = (RoomLanguage)packet.ReadByte();
            packet.ReadString();
            byte count = packet.ReadByte();

            if (count > 0)
            {
                List <IPEndPoint> servers = new List <IPEndPoint>();

                for (int i = 0; i < count; i++)
                {
                    IPAddress ip   = packet.ReadIP();
                    ushort    port = packet.ReadUInt16();
                    servers.Add(new IPEndPoint(ip, port));
                }

                this.Servers = servers.ToArray();
            }
            else
            {
                this.Servers = new IPEndPoint[] { }
            };
        }
Exemplo n.º 3
0
        private void LoadCache()
        {
            List <byte> list = new List <byte>();

            try { list.AddRange(File.ReadAllBytes(Settings.DataPath + "cache.dat")); }
            catch { }

            if (list.Count > 0)
            {
                UdpPacketReader buf = new UdpPacketReader(list.ToArray());
                list.Clear();
                list = null;

                while (buf.Remaining() > 0)
                {
                    ChannelListItem item = new ChannelListItem();
                    item.IP   = buf.ReadIP();
                    item.Port = buf.ReadUInt16();
                    item.Lang = (RoomLanguage)buf.ReadByte();
                    item.Name = buf.ReadString();
                    StringBuilder sb = new StringBuilder();
                    int           i;

                    foreach (char c in item.Name.ToUpper().ToCharArray())
                    {
                        i = (int)c;

                        if ((i >= 65 && i <= 90) || (i >= 48 && i <= 57))
                        {
                            sb.Append(c);
                        }
                    }

                    item.StrippedName  = sb.ToString();
                    item.Topic         = buf.ReadString();
                    item.StrippedTopic = Helpers.StripColors(Helpers.FormatAresColorCodes(item.Topic)).ToUpper();
                    item.Users         = buf.ReadUInt16();
                    full_channel_list.Add(item);
                    ChannelListViewItem vitem = new ChannelListViewItem(item.StrippedName, item.Users);
                    this.gfx.RenderChannelListItem(vitem, item);
                    this.gfx_items.Add(vitem);
                }

                buf = null;
                this.FilterResults();
            }
        }