Beispiel #1
0
 private void m_SendRequestFile()
 {
     #if VERBOSE
     CKernel.LogClient.AddLog("SendRequestFile",m_ID);
     #endif
     m_LastDownloadRequest=DateTime.Now;
     m_DownloadTries++;
     if (DownFileHash==null) return;
     m_DownloadElement=(CElement)CKernel.FilesList[DownFileHash];
     if (m_DownloadElement==null) return;
     MemoryStream packet=new MemoryStream();
     CFileRequest fileRequest;
     if ((m_EmuleProtocol)&&(m_VersionExtendedRequest>0))
     {
     fileRequest=new CFileRequest(DownFileHash,m_DownloadElement.File.ChunksStatus,packet);
     }
     else
     {
     fileRequest=new CFileRequest(DownFileHash,null,packet);
     }
     //          if (connection!=null)
     //          {
     //              connection.SendPacket(packet);
     //          }
     //packet=new MemoryStream();
     packet.Seek(0,SeekOrigin.End);
     CIDFileChange IDFileChange=new CIDFileChange(DownFileHash,packet);
     //          if (connection!=null)
     //          {
     //              connection.SendPacket(packet);
     //          }
     // ver si hay que pedir fuentes
     if (m_AllowSourceExchangeRequest())
     {
     #if VERBOSE
     CKernel.LogClient.AddLog("m_SendRequestFile-RequestSources",m_ID);
     #endif
     Debug.WriteLine(DateTime.Now.ToLongTimeString()+" : Requesting SourceExchange "+m_DownloadElement.File.FileName+" to "+ m_UserName+" | FileHash = "+ CKernel.HashToString(DownFileHash));
     //MemoryStream sourcesPacket=new MemoryStream();
     packet.Seek(0,SeekOrigin.End);
     CRequestSourceExchange requestSourceExchange=new CRequestSourceExchange(packet,DownFileHash);
     if (connection!=null)
     {
         m_LastSourcesRequest=DateTime.Now;
         m_DownloadElement.SourcesList.SetLastSourceExchangeRequest();
         //connection.SendPacket(sourcesPacket);
     }
     }
     if (connection!=null)
     {
     connection.SendPacket(packet);
     }
 }
Beispiel #2
0
 public void ProcessRequestFileID(byte[] packet)
 {
     #if VERBOSE
     CKernel.LogClient.AddLog("ProcessRequestFileID",m_ID);
     #endif
     CIDFileChange IDFileChange=new CIDFileChange(new MemoryStream(packet));
     if (!CKernel.SameHash(ref m_UpFileHash,ref IDFileChange.FileHash))
     {
     m_UpFileHash=IDFileChange.FileHash;
     m_UploadElement=(CElement)CKernel.FilesList[m_UpFileHash];
     }
     if ((m_UploadElement==null)||(m_UploadElement.File.Empty))
     {
     //Debug.Write("No se encontro fichero (Cambio ID) \n");
     MemoryStream buffer=new MemoryStream();
     CNoFile noFile=new CNoFile(buffer,m_UpFileHash);
     m_UpFileHash=null;
     if (connection!=null)
     {
         connection.SendPacket(buffer);
     }
     #if VERBOSE
     CKernel.LogClient.AddLog("ProcessRequestFileID-No found",m_ID);
     #endif
     }
     else
     {
     #if VERBOSE
     CKernel.LogClient.AddLog("ProcessRequestFileID-send file status",m_ID);
     #endif
     MemoryStream packetState=new MemoryStream();
     CFileStatus fileState;
     if (m_UploadElement.File.Completed)
     {
         fileState=new CFileStatus(m_UpFileHash,null,packetState);
     }
     else
     {
         fileState=new CFileStatus(m_UpFileHash,m_UploadElement.File.ChunksStatus,packetState);
     }
     if (connection!=null)
     {
         connection.SendPacket(packetState);
     }
     }
 }