Esempio n. 1
0
        /// <summary>
        /// 更改好友状态 是否在线
        /// </summary>
        /// <param name="value"></param>
        public void UpdateFriendOnline(bool value)
        {
            OnLine = value;

            if (!OnLine)
            {
                if (avForm!=null)
                {
                    if (!avForm.IsDisposed)
                    {
                        avForm.isBtn_hangup = true;
                        avForm.AVClose();
                        avForm = null;
                    }
                }

                if (ravForm != null)
                {
                    if (!ravForm.IsDisposed)
                    {
                        ravForm.isBtn_hangup = true;
                        ravForm.AVClose();
                        ravForm = null;
                    }
                }

                if (fileTansfersContainer.Controls.Count > 0)
                {

                    List<FileTransfersItem> FTIList = new List<FileTransfersItem>();
                    foreach (Control citem in fileTansfersContainer.Controls)
                    {
                        FileTransfersItem item = citem as FileTransfersItem;
                        FTIList.Add(item);
                    }

                    foreach (FileTransfersItem item in FTIList)
                    {
                        if (item.Style == FileTransfersItemStyle.Send)
                        {
                            SendFileManager sendFileManager = item.Tag as SendFileManager;
                            udpSendFile.CancelSend(sendFileManager.MD5);
                            fileTansfersContainer.RemoveItem(item);
                            item.Dispose();
                        }
                        else if (item.Style == FileTransfersItemStyle.ReadyReceive)
                        {
                            RequestSendFileEventArgs rse = item.Tag as RequestSendFileEventArgs;
                            if (rse != null)
                            {
                                rse.Cancel = true;
                                fileTansfersContainer.RemoveItem(item);
                                item.Dispose();
                                udpReceiveFile.AcceptReceive(rse);
                            }
                        }
                        else if (item.Style == FileTransfersItemStyle.Receive)
                        {
                            ControlTag tag = item.Tag as ControlTag;
                            if (tag != null)
                            {
                                udpReceiveFile.CancelReceive(tag.MD5, tag.RemoteIP);
                                fileTansfersContainer.RemoveItem(item);
                                item.Dispose();
                            }
                        }
                        Thread.Sleep(500);
                    }

                    if (panel_function.Visible)
                    {
                        panel_function.Visible = false;
                        this.Width = this.Width - panel_function.Width;
                        panel_msg.Width = panel_msg.Width + panel_function.Width + 2;

                    }

                }

            }

            VcardIq viq = new VcardIq(IqType.get, TO_Jid);
            XmppConn.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);
        }
Esempio n. 2
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            try
            {
                Util.ChatForms.Remove(TO_Jid.Bare);
            }
            catch (Exception)
            {

            }

            try
            {
                XmppConn.MessageGrabber.Remove(TO_Jid);
            }
            catch (Exception)
            {

            }

            try
            {
                udpReceiveFile.Dispose();
                udpReceiveFile = null;
            }
            catch (Exception)
            {

            }

            try
            {
                udpSendFile.Dispose();
                udpSendFile = null;
            }
            catch (Exception)
            {

            }

            RTBRecord.Dispose();
            RTBRecord = null;

            rtfSend.Dispose();
            rtfSend = null;

            if (QQcm_send_key != null)
            {
                QQcm_send_key.Dispose();
                QQcm_send_key = null;
            }

            try
            {
                if (avForm != null)
                {
                    avForm.AVClose();
                    avForm.Dispose();
                    avForm = null;
                }

            }
            catch (Exception)
            {

            }

            try
            {
                if (ravForm != null)
                {
                    ravForm.AVClose();
                    ravForm.Dispose();
                    ravForm = null;
                }
            }
            catch (Exception)
            {

            }

            try
            {
                LB_sockUDP.CloseSock();
                LB_sockUDP.Dispose();
                LB_sockUDP = null;
            }
            catch (Exception)
            {

            }

            if (emotionDropdown != null)
            {
                emotionDropdown.Dispose();
            }

            if (main_msg != null)
            {
                main_msg = null;
            }

            if (PicQueue != null)
            {
                PicQueue.Dispose();
                PicQueue.Clear();
                PicQueue = null;
            }

            if (Opposite != null)
            {
                Opposite = null;
            }

            if (imageP2Ps != null)
            {
                imageP2Ps.Dispose();
                imageP2Ps.Clear();
                imageP2Ps = null;
            }

            if (Close_Check!=null)
            {
                Close_Check.Enabled = false;
                Close_Check.Dispose();
                Close_Check = null;
            }

            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);

            System.GC.Collect();
        }
Esempio n. 3
0
        /// <summary>
        /// 同意视频信息后,进行初使化本地视频服务
        /// </summary>
        /// <param name="msg"></param>
        void AcceptVideoInitMethod(CSS.IM.XMPP.protocol.client.Message msg)
        {
            UserInfo user1;
            UserInfo user2;

            if (ravForm != null && !ravForm.IsDisposed)
            {
                try
                {
                    ravForm.Dispose();
                    ravForm = null;
                }
                catch (Exception)
                {
                }
            }
            else
            {
                ravForm = new CSS.IM.App.Controls.AVForm(TO_Jid);
                ravForm.AVCloseEvent += new CSS.IM.App.Controls.AVForm.AVCloseDelegate(avForm_AVCloseEvent);
            }

            //保存本地视频的监听端口
            ListenVideoUDPPort = ravForm.aVcommunicationEx1.selfUDPPort;

            RemotVideoUDPPort = msg.GetTagInt("UDPPort");
            RemotVideoUDPIP = IPAddress.Parse(msg.GetTag("UDPIP"));

            user1 = new UserInfo();

            user1.LocalPort = RemotVideoUDPPort;
            user1.LocalIP = RemotVideoUDPIP;

            ravForm.SetRemoteAddress(user1, RemotVideoUDPPort);

            user2 = new UserInfo();
            user2.LocalIP = Program.LocalHostIP;
            user2.LocalPort = ListenVideoUDPPort;
            ravForm.SetLocalAddress(user2);
            ravForm.AgreeEvent += new CSS.IM.App.Controls.AVForm.AgreeDelegate(ravForm_AgreeEvent);//接收视频会话事件
            ravForm.btn_hangup.Visible = false;//挂断不可用
            ravForm.btn_agree.Visible = true;//接受可用
            ravForm.btn_refuse.Visible = true;//拒绝可用
            try
            {
                ravForm.Show();
            }
            catch (Exception)
            {

            }

            //if (ravForm.callSoundPlayer != null)
            //    ravForm.callSoundPlayer.Stop();
        }