public void OnDisconnect(byte reason) { connection=null; if (m_SharedFilesRequested) CLog.Log(Constants.Log.Notify,"CLI_DONT_SEND_SHARED",m_UserName); m_SharedFilesRequested=false; #if VERBOSE CKernel.LogClient.AddLog("OnDisconnect-Client",m_ID); #endif #if DEBUG string strReason=CKernel.Globalization["UNK_REASON"]; switch ((Protocol.ConnectionReason)reason) { case Protocol.ConnectionReason.CannotConnect: strReason=CKernel.Globalization["CANT_CONNECT"]; break; case Protocol.ConnectionReason.ClosedConnection: strReason=CKernel.Globalization["CONNECTION_CLOSED"]; break; case Protocol.ConnectionReason.NullPacket: strReason=CKernel.Globalization["NULL_PACKET"]; break; case Protocol.ConnectionReason.NullID: strReason=CKernel.Globalization["NULL_ID"]; break; case Protocol.ConnectionReason.InvalidHeader: strReason=CKernel.Globalization["INVALID_HEADER"]; break; case Protocol.ConnectionReason.TimeOut: strReason=CKernel.Globalization["TIMEOUT"]; break; } #endif #if VERBOSE CKernel.LogClient.AddLog("OnDisconnect-"+strReason,m_ID); #endif if (m_ChatMessages!=null) { m_ChatMessages.Clear(); m_ChatMessages=null; } if (m_UploadState==Protocol.UploadState.Uploading) { CancelUploadTransfer(true); } if ((m_UploadState==Protocol.UploadState.Connecting) || (m_UploadState==Protocol.UploadState.WaitCallBack)) { CancelUploadTransfer(false); } if ((m_DownloadState==Protocol.DownloadState.Connecting) ||(m_DownloadState==Protocol.DownloadState.WaitCallBack)) { if ((m_ConexionTries<Protocol.ConnectionRetries) &&(reason==(byte)Protocol.ConnectionReason.CannotConnect)) { #if DEBUG m_UserName=strReason; #endif Connect(); } else { //quitar la fuente m_ConexionTries=0; m_DownloadState=Protocol.DownloadState.None; if (DownFileHash!=null) { if (m_OtherDownFiles!=null) { m_OtherDownFiles.Clear(); } m_OtherDownFiles=null; if (m_DownloadElement==null) { m_DownloadElement=(CElement)CKernel.FilesList[DownFileHash]; } if ((m_DownloadElement!=null)&&(m_DownloadElement.SourcesList!=null)) m_DownloadElement.SourcesList.RemoveSource(this); } else { Debug.WriteLine(m_UserName+"Never should enter here-> null DownFileHash"); } #if DEBUG m_UserName=strReason; #endif } } if (m_DownloadState==Protocol.DownloadState.Connected) { m_DownloadState=Protocol.DownloadState.None; if (m_DownloadElement==null) { m_DownloadElement=(CElement)CKernel.FilesList[DownFileHash]; } m_DownloadElement.SourcesList.RemoveSource(this); } //free all pending blocks if (m_DownloadState==Protocol.DownloadState.Downloading) { //CLog.Log(Constants.Log.Verbose,"Transfer interrrupted,reason: {0}",strReason); m_CleanDownloadBlocks(); m_LastDownloadRequest=DateTime.Now; m_DownloadSpeeds.Clear(); m_DownloadSpeed=0; m_QRDownload=0; m_DownloadState=Protocol.DownloadState.OnQueue; } //for eny reason some clients (edonkeys mainly) have pending blocks but their downloadstate!=Downloading if (m_DownloadBlocks.Count>0) { m_CleanDownloadBlocks(); // Debug.WriteLine(m_DownloadState.ToString()); // Debug.WriteLine("Disconnected leaving pending blocks!!!"); } CKernel.ClientsList.IsClientNeeded(this); }
public void ProcessChunksStatus(MemoryStream packet, bool udpConnection) { #if VERBOSE CKernel.LogClient.AddLog("ProcessChunksStatus",m_ID); #endif if ((DownFileHash==null)||(m_DownloadElement==null)) return; CFileStatus fileStatus=new CFileStatus(packet,!udpConnection); if ((!udpConnection)&&(!CKernel.SameHash(ref DownFileHash,ref fileStatus.FileHash))) { Exception e=new Exception("Chunks status: invalid fileHash"); throw(e); } if (!CKernel.SameHash(ref DownFileHash,ref m_DownloadElement.File.FileHash)) { m_DownloadElement=CKernel.FilesList[DownFileHash]; } if ((CHash.GetChunksCount(m_DownloadElement.File.FileSize)!=fileStatus.nChunks) && (fileStatus.nChunks!=0)) { Debug.Write("Received chunks numer does not match with file chunks numer\n"); m_DownFileChunks=null; } if (m_DownloadElement.SourcesList!=null) m_DownloadElement.SourcesList.RemoveChunksAvaibility(m_DownFileChunks); uint nChunks=CHash.GetChunksCount(m_DownloadElement.File.FileSize); if (fileStatus.Chunks==null) { if ((m_DownFileChunks==null)||(m_DownFileChunks.Length!=nChunks)) { m_DownFileChunks=new byte[nChunks]; } for (int i=0; i!=m_DownFileChunks.Length; i++) { m_DownFileChunks[i]=(byte)Protocol.ChunkState.Complete; } //TODO hay alguna función para hacer esto en .NET equivalente a memset? } else { if ((m_DownFileChunks==null)||(m_DownFileChunks.Length!=nChunks)) { m_DownFileChunks=new byte[nChunks]; } Buffer.BlockCopy(fileStatus.Chunks,0,m_DownFileChunks,0,fileStatus.Chunks.Length); } if (fileStatus.nChunks>0) { m_DownloadState=Protocol.DownloadState.NoNeededParts; for (int i=0; i!=m_DownFileChunks.Length; i++) { if (((Protocol.ChunkState)m_DownFileChunks[i]==Protocol.ChunkState.Complete) &&((m_DownloadElement.File.ChunksStatus.Length==0) ||((Protocol.ChunkState)m_DownloadElement.File.ChunksStatus[i]!=Protocol.ChunkState.Complete))) { m_DownloadState=Protocol.DownloadState.OnQueue; break; } } } else { m_DownloadState=Protocol.DownloadState.OnQueue; } //m_DownloadElement.SourcesList.UpdateChunksAvaibility(); if (m_DownloadElement.SourcesList!=null) m_DownloadElement.SourcesList.AddChunksAvaibility(m_DownFileChunks); if (udpConnection) return; packet.Close(); packet=null; // ver si necesitamos el hashset del fichero(si no lo tenemos aun lo pedimos) // CElement Element=(CElement)CKernel.FilesList[CKernel.HashToString(DownFileHash)]; // TODO no es necesario pedir hashSets de ficheros de una única parte if ((m_DownloadElement.File.HashSetNeeded())&&(m_DownloadState!=Protocol.DownloadState.NoNeededParts)) { #if VERBOSE CKernel.LogClient.AddLog("ProcesarInformacionPartesFichero-Pide HashSet",m_ID); #endif m_DownloadState=Protocol.DownloadState.ReqestHashSet; MemoryStream responsePacket=new MemoryStream(); CHashSetRequest hashSet=new CHashSetRequest(DownFileHash,responsePacket); if (connection!=null) { connection.SendPacket(responsePacket); } } else { if (m_DownloadState!=Protocol.DownloadState.NoNeededParts) { #if VERBOSE CKernel.LogClient.AddLog("ProcesarInformacionPartesFichero-Envía IniciarDescarga",m_ID); #endif MemoryStream responsePacket=new MemoryStream(); CStartDownload startDonwload=new CStartDownload(responsePacket,DownFileHash); if (connection!=null) { connection.SendPacket(responsePacket); } } } }
public void Connect() { #if VERBOSE CKernel.LogClient.AddLog("Connect",m_ID); #endif m_ConexionTries++; if (m_ID>Protocol.LowIDLimit) { if (connection==null) { connection=new CConnection(m_ID,m_Port,this); } else { connection.ReOpenConnection(); } MemoryStream packet=new MemoryStream(); #if VERBOSE CKernel.LogClient.AddLog("Connect-send hello",m_ID); #endif bool allowPartner=((this.m_DownloadState!=Protocol.DownloadState.NoNeededParts)&& (CKernel.Queue.AllowNewParner())); CSendHello sendHello=new CSendHello(false,packet,CKernel.ServersList.ActiveServer,true,allowPartner); if (connection!=null) { connection.SendPacket(packet); connection.Connect(); } } else { m_CallBackTime=DateTime.Now; if (m_DownloadState==Protocol.DownloadState.Connecting) { m_DownloadState=Protocol.DownloadState.WaitCallBack; } if (m_UploadState==Protocol.UploadState.Connecting) { m_UploadState=Protocol.UploadState.WaitCallBack; } if (CKernel.ServersList.IsTheActiveServer(m_ServerIP,m_ServerPort)) { CKernel.ServersList.ActiveServer.RequestCallBack(m_ID); #if VERBOSE CKernel.LogClient.AddLog("Connect-RequestCallBack",m_ID); #endif } else { #if VERBOSE CKernel.LogClient.AddLog("LowID other server-Connect-RequestCallBack",m_ID); #endif //don't request udp callbacks to save servers bandwidth //this source will be deleted later //CKernel.ServersList.RequestCallBackUDP(m_ServerIP,m_ServerPort,m_ID); } } #if VERBOSE CKernel.LogClient.AddLog("Connect-connected ",m_ID); #endif }
public void FileNotFound(byte[] packet) { // delete source #if VERBOSE CKernel.LogClient.AddLog("FileNotFound",m_ID); #endif m_ClientFileName=CKernel.Globalization["FILE_NOT_FOUND"]; Protocol.DownloadState prevState=m_DownloadState; m_DownloadState=Protocol.DownloadState.None; if (packet.Length!=16) { //raise exception Exception e=new Exception("Invalid packet size"); throw(e); } if (!CKernel.SameHash(ref DownFileHash,ref packet)) { DownFileHash=packet; } if ((DownFileHash!=null)&&(m_DownloadElement==null)) { m_DownloadElement=(CElement)CKernel.FilesList[DownFileHash]; } if ((m_DownloadElement!=null)&&(m_DownloadElement.SourcesList!=null)) { if (prevState==Protocol.DownloadState.Downloading) { m_CleanDownloadBlocks(); m_LastDownloadRequest=DateTime.Now; m_DownloadSpeeds.Clear(); m_DownloadSpeed=0; m_QRDownload=0; } m_DownloadElement.SourcesList.RemoveSource(this); } }
private void InitializeClient(ushort in_Port,uint in_IP,uint in_ServerIP,ushort in_ServerPort,byte[] in_DownFileHash) { m_Port=in_Port; m_strIP=in_IP.ToString(); m_ID=in_IP; m_ServerIP=in_ServerIP; m_ServerPort=in_ServerPort; m_ClientFileName=""; m_LastDownloadRequest=DateTime.MinValue; m_LastSourcesRequest=DateTime.MinValue; m_SourceExchangeVersion=1; m_DownloadTries=0; m_Software=(byte)Protocol.Client.Unknown; if (in_DownFileHash!=null) { DownFileHash=in_DownFileHash; } else { DownFileHash=null; } m_DownloadState=Protocol.DownloadState.None; m_UploadState=Protocol.UploadState.None; m_UploadBlocks=new ArrayList(); m_UploadDataPackets=new ArrayList(); m_DownloadBlocks=new ArrayList(); m_UploadElement=null; m_ConexionTries=0; #if DEBUG IPAddress DirectionIP=new IPAddress(in_IP); m_UserName=DirectionIP.ToString()+":"+Convert.ToString(m_Port); #else m_UserName="******"; #endif m_DownloadSpeeds=new ArrayList(); m_UploadSpeeds=new ArrayList(); m_LastChunkRequested=-1; m_SentComment=false; m_AskingUDP=true; m_SharedFilesRequested=false; m_CallBackTime=DateTime.MinValue; m_FriendLevel=Types.Constants.FriendLevel.NoFriend; m_FirstMessage=true; m_IsSpammer=false; m_IsPartner=false; m_PartnerAllowed=false; m_SupportsPartner=false; m_BadPartnerTime=DateTime.MinValue; m_PartnerStartedTime=DateTime.MinValue; }
private void m_OnConnetionReady() { #if VERBOSE CKernel.LogClient.AddLog("m_OnConnetionReady",m_ID); #endif m_ConexionTries=0; if ((m_UploadState==Protocol.UploadState.Connecting) || (m_UploadState==Protocol.UploadState.WaitCallBack)) { m_UploadState=Protocol.UploadState.Uploading; StartUpload(); } if (m_DownloadState==Protocol.DownloadState.Connecting) { m_DownloadState=Protocol.DownloadState.Connected; TryDownload(); } if (m_DownloadState==Protocol.DownloadState.WaitCallBack) { m_DownloadState=Protocol.DownloadState.Connected; TryDownload(); } if (m_SharedFilesRequested) RequestSharedList(); if ((m_ChatMessages!=null)&&(m_ChatMessages.Count>0)) SendChatMessage(""); }
public void TryDownload() { #if VERBOSE CKernel.LogClient.AddLog("Intentar Descarga",m_ID); #endif DateTime ant_ultimapeticion=m_LastDownloadRequest; m_LastDownloadRequest=DateTime.Now; m_AskingUDP=false; if ((connection!=null)&&(connection.Connected)) { if (m_DownloadState!=Protocol.DownloadState.Downloading) { m_DownloadState=Protocol.DownloadState.Connected; m_SendRequestFile(); } } else { if (CKernel.ConnectionsList.Count()>CKernel.Preferences.GetInt("MaxConnections")) { m_LastDownloadRequest=ant_ultimapeticion+new TimeSpan(0,0,30); return; } if (m_ID<Protocol.LowIDLimit) { if (CKernel.Preferences.GetUInt("ID")>Protocol.LowIDLimit) { m_LastDownloadRequest=DateTime.Now; m_UserName=m_UserName+"(LowID)"; m_DownloadState=Protocol.DownloadState.Connecting; Connect(); } else { m_UserName="******"; } } else { #if VERBOSE CKernel.LogClient.AddLog("Try Download,connect",m_ID); #endif m_DownloadState=Protocol.DownloadState.Connecting; Connect(); } } }
private void CancelDownloadTransfer(bool cleaningFromsourcesList) { #if VERBOSE CKernel.LogClient.AddLog("CancelDownloadTransfer",m_ID); #endif Debug.Write("Cancelling transfer with "+m_UserName+"\n"); //CLog.Log(Constants.Log.Verbose,"Cancelling transfer no need parts"); MemoryStream packet=new MemoryStream(); CCancelTransfer cancelarCmd=new CCancelTransfer(packet); if (connection!=null) { connection.SendPacket(packet); } m_CleanDownloadBlocks(); m_DownloadSpeeds.Clear(); m_DownloadSpeed=0; m_DownloadState=Protocol.DownloadState.None; //try to change to other file to continue downloading if the client has other file we need if ((m_OtherDownFiles!=null) && (m_OtherDownFiles.Count>0) && (!cleaningFromsourcesList)) { m_DownloadElement.SourcesList.RemoveSource(this); } }
public void RequestBlocks() { #if VERBOSE CKernel.LogClient.AddLog("RequestBlocks,download blocks.count:"+Convert.ToString(m_DownloadBlocks.Count),m_ID); #endif if (m_DownloadElement==null) { if (DownFileHash!=null) { m_DownloadElement=(CElement)CKernel.FilesList[DownFileHash]; if ((m_DownloadElement!=null)&&(m_DownloadElement.SourcesList!=null)) { m_DownloadElement.SourcesList.AddSource(this); } else { // probablemente el fichero ya se ha completado return; } } else { return; } } m_DownloadState=Protocol.DownloadState.Downloading; //CElement Element=(CElement)CKernel.FilesList[CKernel.HashToString(DownFileHash)]; uint start=0; uint end=0; int chunk=0; CFileBlock[] blocks=new CFileBlock[3]; for (uint i=0; i!=3; i++) { blocks[i]=new CFileBlock(); //Debug.Write("LastChunk:"+m_LastChunkRequested.ToString()); chunk=m_DownloadElement.SourcesList.SelectChunk(m_DownFileChunks,m_LastChunkRequested); m_LastChunkRequested=chunk; //Debug.WriteLine("NewChunk:"+m_LastChunkRequested.ToString()); if (chunk>=0) { if (m_DownloadElement.File.GetNewBlockInChunk((uint)chunk,ref start,ref end)) { blocks[i].start=start; blocks[i].end=end; blocks[i].FileHash=DownFileHash; blocks[i].position=start; //blocks[i].buffer=new Byte[fin+1-inicio]; m_DownloadBlocks.Add(blocks[i]); if ((end==0)&&(start==0)) { Debug.WriteLine("no more blocks to request "+Convert.ToString(chunk)); } else { //Debug.WriteLine(m_UserName+", ChunksStatus = "+Convert.ToString(m_DownloadElement.File.ChunksStatus[0])/*+Convert.ToString(m_DownloadElement.File.GetChunksStatus()[1])*/); #if VERBOSE CKernel.LogClient.AddLog("RequestBlocks-chunk requested "+Convert.ToString(chunk)+" block: "+Convert.ToString(start)+"-"+Convert.ToString(end)+"\n",m_ID); #endif } } } } if ((blocks[0].start==0)&&(blocks[0].end==0)) { #if VERBOSE CKernel.LogClient.AddLog("RequestBlocks-first block is null,no request blocks",m_ID); #endif #if DEBUG Debug.WriteLine(m_UserName+" Parte: "+Convert.ToString(chunk)+" first block is null,no request blocks"); for (int j=0; j<m_DownloadElement.File.ChunksStatus.Length; j++) { if (((m_DownloadElement.File.ChunksStatus[j]==(byte)Protocol.ChunkState.Empty)|| (m_DownloadElement.File.ChunksStatus[j]==(byte)Protocol.ChunkState.InProgress))&& (m_DownFileChunks[j]==(byte)Protocol.ChunkState.Complete)) Debug.WriteLine("Chunk not selected when available"); } #endif if (m_DownloadBlocks.Count==0) { //no needed new blocks to download and nothing pending for receiving bool willBeChangedToOtherFile=((m_OtherDownFiles!=null)&&(m_OtherDownFiles.Count>0)); CancelDownloadTransfer(false); if (!willBeChangedToOtherFile) { m_DownloadState=Protocol.DownloadState.NoNeededParts; } } } else { MemoryStream packet=new MemoryStream(); CFileBlockRequest fileBlockRequest=new CFileBlockRequest(packet,DownFileHash,ref blocks[0],ref blocks[1],ref blocks[2]); if (connection!=null) { connection.SendPacket(packet); } } }
public void SwapToOtherFile() { if ((m_OtherDownFiles==null)||(m_OtherDownFiles.Count==0)) { return; } byte highestPriority=0; CElement tmpElement=null; CElement Element=null; int i=0; do { tmpElement=(CElement)CKernel.FilesList[CKernel.StringToHash(m_OtherDownFiles[i])]; if ((tmpElement!=null) &&(tmpElement.SourcesList!=null) &&(!tmpElement.File.Completed) &&(tmpElement.File.FileStatus==Protocol.FileState.Ready)) { if ((byte)tmpElement.File.DownPriority>=highestPriority) { Element=tmpElement; highestPriority=(byte)tmpElement.File.DownPriority; } i++; } else { m_OtherDownFiles.RemoveAt(i); } } while ((i<m_OtherDownFiles.Count)&&(m_OtherDownFiles.Count>0)); // element selected to download if (Element!=null) { m_OtherDownFiles.Remove(CKernel.HashToString(Element.File.FileHash)); DownFileHash=new byte[16]; Buffer.BlockCopy(Element.File.FileHash,0,DownFileHash,0,16); m_DownloadElement=Element; m_ClientFileName=""; m_DownloadElement.SourcesList.AddSource(this); if ((connection!=null)&&connection.Connected) { m_DownloadState=Protocol.DownloadState.Connected; TryDownload(); } else { m_DownloadState=Protocol.DownloadState.None; } } }
public void RemoveDownload() { #if VERBOSE CKernel.LogClient.AddLog("RemoveDownload",m_ID); #endif if (m_DownloadState==Protocol.DownloadState.Downloading) { CancelDownloadTransfer(true); } CKernel.SourcesOld.AddClient(this); // DownFileHash=null; // m_DownFileChunks=null; m_DownloadElement=null; m_DownloadState=Protocol.DownloadState.None; }
public CClient(CConnection in_connection) { connection=in_connection; m_UploadBlocks=new ArrayList(); m_UploadDataPackets=new ArrayList(); m_DownloadBlocks=new ArrayList(); m_DownloadState=Protocol.DownloadState.None; m_UploadState=Protocol.UploadState.None; m_UploadElement=null; m_LastSourcesRequest=DateTime.MinValue; m_DownloadTries=0; m_ClientFileName=""; m_Software=(byte)Protocol.Client.Unknown; m_DownloadSpeeds=new ArrayList(); m_UploadSpeeds=new ArrayList(); m_SentComment=false; m_LastChunkRequested=-1; m_AskingUDP=true; m_SharedFilesRequested=false; m_CallBackTime=DateTime.MinValue; m_FriendLevel=Types.Constants.FriendLevel.NoFriend; m_FirstMessage=true; m_IsSpammer=false; m_IsPartner=false; m_PartnerAllowed=false; m_SupportsPartner=false; m_BadPartnerTime=DateTime.MinValue; m_PartnerStartedTime=DateTime.MinValue; }
public void ProcessOutOfParts() { #if VERBOSE CKernel.LogClient.AddLog("ProcessOutOfParts",m_ID); #endif //CLog.Log(Constants.Log.Verbose,"Transfer interrupted: out of parts"); m_CleanDownloadBlocks(); m_DownloadSpeeds.Clear(); m_DownloadSpeed=0; m_DownloadState=Protocol.DownloadState.OnQueue; if (DownFileHash!=null) { MemoryStream responsePacket=new MemoryStream(); CStartDownload StartDownload=new CStartDownload(responsePacket,DownFileHash); if (connection!=null) { connection.SendPacket(responsePacket); } } }
public void ProcessHashSet(byte[] packet) { #if VERBOSE CKernel.LogClient.AddLog("ProcessHashSet",m_ID); #endif if (DownFileHash==null) return; Debug.WriteLine("HashSet received,file "+m_DownloadElement.File.FileName+" client "+m_UserName); CHashSetResponse hashSetResponse; if (m_DownloadElement.File.HashSetNeeded()) { hashSetResponse=new CHashSetResponse(new MemoryStream(packet),ref m_DownloadElement.File); } else { Debug.WriteLine("File already has hash"); } m_DownloadState=Protocol.DownloadState.OnQueue; if (!m_DownloadElement.File.HashSetNeeded()) { #if VERBOSE CKernel.LogClient.AddLog("ProcessHashSet-start download",m_ID); #endif MemoryStream responsePacket=new MemoryStream(); CStartDownload startDownload=new CStartDownload(responsePacket,DownFileHash); if (connection!=null) { connection.SendPacket(responsePacket); } } }
public void ProcessFileRequest(byte[] packet) { #if VERBOSE CKernel.LogClient.AddLog("ProcessFileRequest",m_ID); #endif CFileRequest fileRequest=new CFileRequest(new MemoryStream(packet)); if (fileRequest.FileHash==null) return; m_UpFileHash=fileRequest.FileHash; byte[] tmp_UploadFileHash=fileRequest.FileHash; m_UploadElement=(CElement)CKernel.FilesList[m_UpFileHash]; CElement tmpUploadElement=m_UploadElement; if ((m_UploadElement==null)||(m_UploadElement.File.Empty)) { /* Dont need to send no file found,we have sent it already in ProcessRequestFileID * MemoryStream buffer=new MemoryStream(); * CNoFile noFile=new CNoFile(buffer,m_UpFileHash); * m_UpFileHash=null; * m_UploadElement=null; * if (connection!=null) connection.SendPacket(buffer); */ } else { #if VERBOSE CKernel.LogClient.AddLog("ProcessFileRequest-send file info",m_ID); #endif m_UploadElement.Statistics.IncSessionRequests(); if ((fileRequest.Partes!=null) &&(fileRequest.Partes.Length==m_UploadElement.File.NumChunks)) { m_UpFileChunks=fileRequest.Partes; } MemoryStream fileInfoPacket=new MemoryStream(); CFileInfo fileInfo=new CFileInfo(m_UpFileHash,m_UploadElement.File.FileName,fileInfoPacket); if (connection!=null) { connection.SendPacket(fileInfoPacket); } m_SendComment(); } // it can be a new source for downloads if ((tmpUploadElement!=null) &&(tmpUploadElement.SourcesList!=null) &&(!tmpUploadElement.File.Completed) &&(tmpUploadElement.File.FileStatus==Protocol.FileState.Ready)) { if (DownFileHash==null) { #if VERBOSE CKernel.LogClient.AddLog("ProcessFileRequest-add client to downloads",m_ID); #endif DownFileHash=new byte[16]; Buffer.BlockCopy(tmpUploadElement.File.FileHash,0,DownFileHash,0,16); m_DownloadElement=tmpUploadElement; m_DownloadState=Protocol.DownloadState.Connected; if (tmpUploadElement.SourcesList.AddSource(this)) { TryDownload(); } else { m_DownloadState=Protocol.DownloadState.None; } } else { if (!CKernel.SameHash(ref DownFileHash,ref tmpUploadElement.File.FileHash)) AddOtherDownloadFile(CKernel.HashToString(tmp_UploadFileHash)); } } }