コード例 #1
0
 /// <summary>
 /// 文件被接收时触发事件
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnReceiveByte(ReceiveDataEventArgs e)
 {
     if (ReceiveByte != null)
     {
         ReceiveByte(e);
     }
 }
コード例 #2
0
 protected virtual void OnReceiveData(ReceiveDataEventArgs e)
 {
     if (ReceiveData != null)
     {
         ReceiveData(this, e);
     }
 }
コード例 #3
0
        /// <summary>
        /// 继承Udp基类接收数据方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UdpLibraryReceiveData(object sender, ReceiveDataEventArgs e)
        {
            //若不适用内部封装协议则只激活接受原始数据事件
            if (!_isAxAgreement)
            {
                OnReceiveByte(e);
                return;
            }
            MsgCell cell = new MsgCell();

            cell.FromBuffer(e.Buffer);
            switch (cell.MessageId)
            {
            case (int)Command.RequestSendTextMSg:
                OnReceiveTextMsg((MsgTypeCell)cell.Data);
                break;

            case (int)Command.ResponeSendFile:
                OnResponeSendFile((ResponeTraFransfersFile)cell.Data);
                break;

            case (int)Command.ResponeSendFilePack:
                OnResponeSendFilePack((ResponeTraFransfersFile)cell.Data);
                break;

            case (int)Command.RequestCancelReceiveFile:
                OnRequestCancelReceiveFile(cell.Data.ToString());
                break;

            case (int)Command.RequestSendFile:
                OnStartRecieve((TraFransfersFileStart)cell.Data, e.RemoteIP);
                break;

            case (int)Command.RequestSendFilePack:
                OnRecieveBuffer((TraFransfersFile)cell.Data, e.RemoteIP);
                break;

            case (int)Command.RequestCancelSendFile:
                OnRequestCancelSendFile(cell.Data.ToString(), e.RemoteIP);
                break;
            }
        }