コード例 #1
0
ファイル: UdpSendFile.cs プロジェクト: royalvald/UDPTest
        private void SendFileManageReadFileBuffer(
            object sender, ReadFileBufferEventArgs e)
        {
            TraFransfersFile ts = new TraFransfersFile(
                e.Index, e.Buffer);

            Send(1, ts);
        }
コード例 #2
0
        private void SendFileManageReadFileBuffer(
            object sender, ReadFileBufferEventArgs e)
        {
            SendFileManager  sendFileManager = sender as SendFileManager;
            TraFransfersFile ts = new TraFransfersFile(
                sendFileManager.MD5, e.Index, e.Buffer);

            Send((int)Command.RequestSendFilePack, ts);
        }
コード例 #3
0
 private void OnRecieveBuffer(
     TraFransfersFile traFransfersFile,
     IPEndPoint remoteEP)
 {
     _receiveFileManager.ReceiveBuffer(
         traFransfersFile.Index,
         traFransfersFile.Buffer);
     if (_receiveFileManager.PartCount == traFransfersFile.Index + 1)
     {
         Send(2, "OK", remoteEP);
     }
     else
     {
         Send(1, "OK", remoteEP);
     }
 }
コード例 #4
0
ファイル: UdpReceiveFile.cs プロジェクト: Ato42/CMS
        private void OnRecieveBuffer(
            TraFransfersFile traFransfersFile,
            IPEndPoint remoteEP)
        {
            ReceiveFileManager receiveFileManager;

            if (!ReceiveFileManagerList.TryGetValue(
                    traFransfersFile.MD5,
                    out receiveFileManager))
            {
                return;
            }
            if (receiveFileManager != null)
            {
                ResponeTraFransfersFile responeTraFransfersFile;
                int size = receiveFileManager.ReceiveBuffer(
                    traFransfersFile.Index,
                    traFransfersFile.Buffer);

                if (receiveFileManager.Completed)
                {
                    responeTraFransfersFile = new ResponeTraFransfersFile(
                        traFransfersFile.MD5,
                        size,
                        -2);
                    Send(
                        (int)Command.ResponeSendFilePack,
                        responeTraFransfersFile,
                        remoteEP);
                }
                else
                {
                    responeTraFransfersFile = new ResponeTraFransfersFile(
                        traFransfersFile.MD5,
                        size,
                        receiveFileManager.GetNextReceiveIndex());
                    Send(
                        (int)Command.ResponeSendFilePack,
                        responeTraFransfersFile,
                        remoteEP);
                }
                OnFileReceiveBuffer(
                    new FileReceiveBufferEventArgs(
                        receiveFileManager, traFransfersFile.Buffer.Length));
            }
        }