コード例 #1
0
        private void btn_open_Click(object sender, EventArgs e)
        {
            udpSendFile = new UdpSendFile(int.Parse(txt_sendLocalPort.Text));
            //sendFile.Log += new TraFransfersFileLogEventHandler(SendFileLog);
            udpSendFile.FileSendBuffer += new FileSendBufferEventHandler(FileSendBuffer);
            udpSendFile.FileSendAccept += new FileSendEventHandler(FileSendAccept);
            udpSendFile.FileSendRefuse += new FileSendEventHandler(FileSendRefuse);
            udpSendFile.FileSendCancel += new FileSendEventHandler(FileSendCancel);
            udpSendFile.FileSendComplete += new FileSendEventHandler(FileSendComplete);
            udpSendFile.Start();
            AppendLog(string.Format("开始侦听,端口:{0}", udpSendFile.Port), false);

            udpReceiveFile = new UdpReceiveFile(int.Parse(txt_receiveLocalPort.Text));
            udpReceiveFile.RequestSendFile +=new RequestSendFileEventHandler(RequestSendFile);
            udpReceiveFile.FileReceiveBuffer +=new FileReceiveBufferEventHandler(FileReceiveBuffer);
            udpReceiveFile.FileReceiveComplete +=new FileReceiveEventHandler(FileReceiveComplete);
            udpReceiveFile.FileReceiveCancel +=new FileReceiveEventHandler(FileReceiveCancel);
            udpReceiveFile.Start();
            AppendLog(string.Format("开始侦听,端口:{0}", udpReceiveFile.Port), false);
        }
コード例 #2
0
        public ChatFromMsg(Jid jid, XmppClientConnection Conn,string nickName)
        {
            InitializeComponent();
            RemotBaseUDPIP = IPAddress.Parse("127.0.0.1");

            AccepVideotInit = new AcceptVideoInitDelegate(AcceptVideoInitMethod);
            ReturnAcceptVideoInit = new ReturnAcceptVideoInitDelegate(ReturnAcceptVideoInitMethod);
            AcceptVideoOpen = new AcceptVideoOpenDelegate(AcceptVideoOpenMethod);
            FileSendRequestEvent = new FileSendRequestDelegate(FileSendRequestMethod);
            FileSendInitEvent = new FileSendInitDelegate(FileSendInitMethod);
            GetFtpFileEvent = new GetFtpFileDelegate(GetFtpFileAMethod);
            Red5AccpetEvent = new Red5AccpetDelegate(Red5AccpetMethod);
            Red5RefuseEvent = new Red5RefuseDelegate(Red5RefuseMethod);

            TO_Jid = jid;
            XmppConn = Conn;
            this._NickName = nickName;
            this.Text = "正在与[" + (nikeName.Text != "" ? nikeName.Text : _NickName) + "]对话";

            VcardIq viq = new VcardIq(IqType.get, new Jid(jid.Bare));
            XmppConn.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);

            Util.ChatForms.Add(TO_Jid.Bare, this);
            nikeName.Text = _NickName;

            rtfSend.AllowDrop = true;
            rtfSend.DragDrop += new DragEventHandler(rtfSend_DragDrop);
            rtfSend.DragEnter += new DragEventHandler(rtfSend_DragEnter);

            XmppConn.MessageGrabber.Add(jid, new BareJidComparer(), new MessageCB(MessageCallback), null);

            //用于外部更新截图
            ScreenImageEvent += new ScreenImageDelegate(ChatFromMsg_ScreenImageEvent);
            Util.TO_Jid =TO_Jid;//公布对外的to_jid用于外部插入截图

            //初使化发送文件
            udpSendFile = new UdpSendFile(2);
            //sendFile.Log += new TraFransfersFileLogEventHandler(SendFileLog);
            udpSendFile.FileSendBuffer += new FileSendBufferEventHandler(FileSendBuffer);
            udpSendFile.FileSendAccept += new FileSendEventHandler(FileSendAccept);
            udpSendFile.FileSendRefuse += new FileSendEventHandler(FileSendRefuse);
            udpSendFile.FileSendCancel += new FileSendEventHandler(FileSendCancel);
            udpSendFile.FileSendComplete += new FileSendEventHandler(FileSendComplete);
            udpSendFile.Start();

            //初使化接收文件
            udpReceiveFile = new UdpReceiveFile(2);
            udpReceiveFile.RequestSendFile += new RequestSendFileEventHandler(RequestSendFile);
            udpReceiveFile.FileReceiveBuffer += new FileReceiveBufferEventHandler(FileReceiveBuffer);
            udpReceiveFile.FileReceiveComplete += new FileReceiveEventHandler(FileReceiveComplete);
            udpReceiveFile.FileReceiveCancel += new FileReceiveEventHandler(FileReceiveCancel);
            udpReceiveFile.Start();
        }
コード例 #3
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();
        }