Beispiel #1
0
 public void addUcf(Friend f)
 {
     UcFriend ucf = new UcFriend();
     ucf.Form = this;
     ucf.CurFriend = f;
     ucf.Top = this.pnFriendlist.Controls.Count * ucf.Height;
     this.pnFriendlist.Controls.Add(ucf);
 }
Beispiel #2
0
        private void listen()
        {
            UdpClient uc = new UdpClient(9527);
            while (true)
            {
                IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 0);
                byte[] bmsg = uc.Receive(ref ipep);
                string msg = Encoding.Default.GetString(bmsg);
                string[] datas =msg.Split('|');
                if (datas.Length != 4)
                {
                    continue;
                }

                if(datas[0] == "LOGIN")
                {
                    Friend friend = new Friend();

                    int curIndex = Convert.ToInt32(datas[2]);

                    if (curIndex<0 || curIndex>=this.ilHeadImages.Images.Count)
                    {
                        curIndex = 0;
                    }

                    friend.HeadImageIndex = curIndex;
                    friend.NickName = datas[1];
                    friend.shuoshuo = datas[3];
                    object[] pars = new object [1];
                    pars[0]=friend;
                    this.Invoke(new delAddFriend(this.addUcf),pars);

                    //UcFriend ucf = new UcFriend();
                    //ucf.CurFriend = friend;
                    //this.pnFriendlist.Controls.Add(ucf);
                }
            }
        }