예제 #1
0
 public FileReceiveBufferEventArgs(
     ReceiveFileManager receiveFileManager,
     int size)
     : base()
 {
     _receiveFileManager = receiveFileManager;
     _size = size;
 }
예제 #2
0
        /// <summary>
        /// 完成接收文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ReceiveFileManagerReceiveFileComplete(
            object sender, FileReceiveCompleteEventArgs e)
        {
            ReceiveFileManager receiveFileManager =
                sender as ReceiveFileManager;

            OnFileReceiveComplete(new FileReceiveEventArgs(receiveFileManager));
            ReceiveFileManagerList.Remove(receiveFileManager.MD5);
        }
예제 #3
0
        private void ReceiveFileManagerReceiveFileTimeout(
            object sender, EventArgs e)
        {
            ReceiveFileManager receiveFileManager =
                sender as ReceiveFileManager;
            ResponeTraFransfersFile responeTraFransfersFile =
                new ResponeTraFransfersFile(
                    receiveFileManager.MD5,
                    0,
                    receiveFileManager.GetNextReceiveIndex());

            Send(
                (int)Command.ResponeSendFilePack,
                responeTraFransfersFile,
                receiveFileManager.RemoteIP);
        }
예제 #4
0
        /// <summary>
        /// 允许接收
        /// </summary>
        /// <param name="e"></param>
        public void AcceptReceive(RequestSendFileEventArgs e)
        {
            TraFransfersFileStart   traFransfersFileStart = e.TraFransfersFileStart;
            IPEndPoint              remoteIP = e.RemoteIP;
            ResponeTraFransfersFile responeTraFransfersFile;

            if (e.Cancel)
            {
                responeTraFransfersFile = new ResponeTraFransfersFile(
                    traFransfersFileStart.MD5, 0, -1);
                Send((int)Command.ResponeSendFile, responeTraFransfersFile, remoteIP);
            }
            else
            {
                ReceiveFileManager receiveFileManager;
                if (!ReceiveFileManagerList.TryGetValue(
                        traFransfersFileStart.MD5,
                        out receiveFileManager))
                {
                    receiveFileManager = new ReceiveFileManager(
                        traFransfersFileStart.MD5,
                        e.Path,
                        traFransfersFileStart.FileName,
                        traFransfersFileStart.PartCount,
                        traFransfersFileStart.PartSize,
                        traFransfersFileStart.Length,
                        remoteIP);
                    receiveFileManager.ReceiveFileComplete +=
                        new FileReceiveCompleteEventHandler(
                            ReceiveFileManagerReceiveFileComplete);
                    receiveFileManager.ReceiveFileTimeout +=
                        new EventHandler(ReceiveFileManagerReceiveFileTimeout);
                    ReceiveFileManagerList.Add(
                        traFransfersFileStart.MD5,
                        receiveFileManager);
                    receiveFileManager.Start();
                }
                responeTraFransfersFile = new ResponeTraFransfersFile(
                    traFransfersFileStart.MD5, 0, 0);
                Send((int)Command.ResponeSendFile, responeTraFransfersFile, remoteIP);
            }
        }
예제 #5
0
 public FileReceiveEventArgs(
     ReceiveFileManager receiveFileManager)
     : base()
 {
     _receiveFileManager = receiveFileManager;
 }