Esempio n. 1
0
 public FileReceiveBufferEventArgs(
     ReceiveFileManager receiveFileManager,
     int size)
     : base()
 {
     _receiveFileManager = receiveFileManager;
     _size = size;
 }
Esempio n. 2
0
        private void ReceiveFileManagerReceiveFileComplete(
            object sender, FileReceiveCompleteEventArgs e)
        {
            ReceiveFileManager receiveFileManager =
                sender as ReceiveFileManager;

            OnFileReceiveComplete(new FileReceiveEventArgs(receiveFileManager));
            ReceiveFileManagerList.Remove(receiveFileManager.MD5);
        }
Esempio n. 3
0
 private void OnStartRecieve(
     TraFransfersFileStart traFransfersFileStart,
     IPEndPoint remoteEP)
 {
     _receiveFileManager = new ReceiveFileManager(
         _path,
         traFransfersFileStart.FileName,
         traFransfersFileStart.PartCount,
         traFransfersFileStart.PartSize,
         traFransfersFileStart.Length);
     Send(0, "OK", remoteEP);
 }
Esempio n. 4
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);
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
 public FileReceiveEventArgs(
     ReceiveFileManager receiveFileManager)
     : base()
 {
     _receiveFileManager = receiveFileManager;
 }