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); }
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)); } }