Exemple #1
0
 public void addUcf(Friend f)
 {
     UcFriend ucf = new UcFriend();
     ucf.Frm=this;
     ucf.CurFriend = f;
     ucf.Top = this.pnFriendsList.Controls.Count * ucf.Height;
     this.pnFriendsList.Controls.Add(ucf);
 }
Exemple #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);
                //MessageBox.Show(msg);
                string[] datas = msg.Split('|');
                if (datas.Length != 4)
                {
                    continue;
                }
                if(datas[0]=="LOGIN")
                {
                    //MessageBox.Show(datas[1]);
                    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);

                }

            }
        }