예제 #1
0
파일: Client.cs 프로젝트: elnomade/hathi
 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);
     }
 }
예제 #2
0
파일: Client.cs 프로젝트: elnomade/hathi
 public void ProcessSourceRequest(byte[] packet)
 {
     #if VERBOSE
     CKernel.LogClient.AddLog("ProcessSourceRequest",m_ID);
     #endif
     MemoryStream requestBuffer=new MemoryStream(packet);
     CRequestSourceExchange requestSourceExchange=new CRequestSourceExchange(requestBuffer);
     requestBuffer.Close();
     requestBuffer=null;
     MemoryStream responsePacket=new MemoryStream();
     CSourceExchangeResponse sourceExchangeResponse=new CSourceExchangeResponse(responsePacket,requestSourceExchange.FileHash,m_ID,m_Port,m_SourceExchangeVersion);
     if (sourceExchangeResponse.nSources>0)
     {
     #if VERBOSE
     CKernel.LogClient.AddLog("Sent "+Convert.ToString(sourceExchangeResponse.nSources)+" sources\n",m_ID);
     #endif
     if (connection!=null)
     {
         connection.SendPacket(responsePacket);
     }
     }
 }