예제 #1
0
        private void HandleFileApply(string MessageStyle, MessageEntity ReceiveMsg)//处理发送文件类消息
        {
            AccessMethod AccMethod = new AccessMethod();
            var          Frm       = AccMethod.findForm(ReceiveMsg.Adress);

            if (Frm != null)
            {
                //消息加入对话窗体控件显示窗体
                TalkWinFrm frm = (TalkWinFrm)Frm;
                if ("FileAplly" == MessageStyle)
                {
                    frm.ReceiveFile(ReceiveMsg);
                }
                else
                {
                    frm.AgreeReceive(ReceiveMsg);
                }
            }
            else
            {
                TalkWinFrm NewFrm = new TalkWinFrm(ReceiveMsg);
                if ("FileAplly" == MessageStyle)
                {
                    NewFrm.ReceiveFile(ReceiveMsg);
                }

                NewFrm.Show();
            }
        }
예제 #2
0
        private void treeList1_DoubleClick(object sender, EventArgs e)//双击打开对话窗体
        {
            if (this.treeList1.DataSource != null && this.treeList1.FocusedNode != null)
            {
                string IP = this.treeList1.FocusedNode["IPAdress"].ToString();
                if (IP == Program.MainEntity.IPAdress)//是自己不做响应
                {
                    return;
                }
                AccessMethod AccMethod = new AccessMethod();
                var          Frm       = AccMethod.findForm(IP);
                if (Frm != null)
                {
                    //消息加入对话窗体控件显示窗体
                    TalkWinFrm frm = (TalkWinFrm)Frm;
                    //frm.FreshChatMessage(ReceiveMessage);
                    frm.Show();
                }
                else
                {
                    MessageEntity ME = new MessageEntity();

                    var FE = from item in Program.FriendList where item.IPAdress == IP select item;
                    ME.MyInformation = FE.First();
                    TalkWinFrm frm = new TalkWinFrm(ME);
                    frm.Show();
                }
            }
        }
예제 #3
0
        private void HandleFileRefuse(MessageEntity ReceiveMsg, bool RefuseOrCancle)//处理发送文件拒绝消息(true是拒绝,false是取消)
        {
            AccessMethod AccMethod = new AccessMethod();
            var          Frm       = AccMethod.findForm(ReceiveMsg.Adress);

            if (Frm != null)
            {
                TalkWinFrm frm = (TalkWinFrm)Frm;
                frm.RefuseFile(ReceiveMsg, RefuseOrCancle);
            }
        }
예제 #4
0
        private void HandleVideoStop(MessageEntity ReceiveMsg)//处理VideoStop类信息
        {
            AccessMethod AccMethod = new AccessMethod();
            var          Frm       = AccMethod.FindVideoFrm(ReceiveMsg.Adress, "视频聊天窗口");

            if (Frm != null)
            {
                //消息加入对话窗体控件显示窗体
                VideoTalkFrm frm = (VideoTalkFrm)Frm;
                frm.ColseAV();
            }
        }
예제 #5
0
        private void HandleVideoStart(MessageEntity ReceiveMsg)//处理VideoStart类信息
        {
            AccessMethod AccMethod = new AccessMethod();
            var          Frm       = AccMethod.FindVideoFrm(ReceiveMsg.Adress, "视频聊天窗口");

            if (Frm != null)
            {
                //消息加入对话窗体控件显示窗体
                VideoTalkFrm frm = (VideoTalkFrm)Frm;
                frm.Connect(ReceiveMsg.Adress, int.Parse(ReceiveMsg.Point));
            }
        }
예제 #6
0
        private void HandleMessage(MessageEntity ReceiveMsg)//处理Message类信息
        {
            //查找好友列表中IP,如果存在,则头像闪烁并记录消息
            var FriendList = from item in Program.FriendList where item.IPAdress == ReceiveMsg.MyInformation.IPAdress select item;

            if (FriendList == null || FriendList.Count() <= 0)
            {
                Program.FriendList.Add(ReceiveMsg.MyInformation);
            }
            AccessMethod AccMethod = new AccessMethod();
            var          Frm       = AccMethod.findForm(ReceiveMsg.Adress);

            if (Frm != null)
            {
                //消息加入对话窗体控件显示窗体
                TalkWinFrm frm = (TalkWinFrm)Frm;
                frm.FreshChatMessage(ReceiveMsg);
            }
            else
            {
                TalkWinFrm NewFrm = new TalkWinFrm(ReceiveMsg);
                NewFrm.Show();
            }
        }
예제 #7
0
        /// <summary>
        /// 消息处理方法
        /// </summary>
        /// <param name="ByteArray">收到的消息体</param>
        private void HandleReceiveByte(byte[] ByteArray)//消息处理
        {
            var ReceiveMessage = (MessageEntity)null;

            try
            {
                ReceiveMessage = (MessageEntity)IMLibrary.Serializers.ByteToObj(ByteArray);
                if (string.IsNullOrEmpty(ReceiveMessage.Flag))
                {
                    return;
                }
                if (string.IsNullOrEmpty(ReceiveMessage.Adress))
                {
                    return;
                }
            }
            catch (Exception ex)
            {
            }
            switch (ReceiveMessage.Flag)
            {
            case "Login":
                //如果有此IP则忽略,否则增加好友列表并给此IP发送消息
                var FriendList = from item in Program.FriendList where item.IPAdress == ReceiveMessage.Adress select item;
                if (FriendList.Count() < 1)
                {
                    Program.FriendList.Add(ReceiveMessage.MyInformation);
                    HandleMethod.UdpBrodcastSend("Login", "", new IPEndPoint(IPAddress.Parse(ReceiveMessage.Adress), 8002));
                    this.treeList1.DataSource = null;
                    this.treeList1.DataSource = Program.FriendList;
                    this.treeList1.Refresh();
                }
                break;

            case "Out":
                //如果有此IP则删除好友,否则忽略
                FriendList = from item in Program.FriendList where item.IPAdress == ReceiveMessage.Adress select item;
                if (FriendList.Count() > 0)
                {
                    foreach (var item in Program.FriendList)
                    {
                        if (item.IPAdress == ReceiveMessage.Adress)
                        {
                            Program.FriendList.Remove(item);
                            this.treeList1.DataSource = null;
                            this.treeList1.DataSource = Program.FriendList;
                            this.treeList1.Refresh();
                            break;
                        }
                    }
                }
                break;

            case "Message":
                //查找好友列表中IP,如果存在,则头像闪烁并记录消息
                FriendList = from item in Program.FriendList where item.IPAdress == ReceiveMessage.Adress select item;
                if (FriendList.Count() > 0)
                {
                    AccessMethod AccMethod = new AccessMethod();
                    var          Frm       = AccMethod.findForm(ReceiveMessage.Adress);
                    if (Frm != null)
                    {
                        //消息加入对话窗体控件显示窗体
                        TalkWinFrm frm = (TalkWinFrm)Frm;
                        frm.FreshChatMessage(ReceiveMessage);
                    }
                    else
                    {
                        TalkWinFrm NewFrm = new TalkWinFrm(ReceiveMessage);
                        //NewFrm.Name = ReceiveMessage.CumputerName;
                        //NewFrm.Tag = ReceiveMessage.Adress;
                        ////消息加入对话窗体控件展示
                        //NewFrm.Text = "和" + ReceiveMessage.MyInformation.TrueName + "聊天中...";
                        NewFrm.Show();
                    }
                }
                else
                {
                    Program.FriendList.Add(ReceiveMessage.MyInformation);
                }
                break;

            default:
                break;
            }
        }