Ejemplo n.º 1
0
        public CServerSearchResults(MemoryStream buffer, CSearcher search, bool esUDP)
        {
            BinaryReader reader = new BinaryReader(buffer);

            if (!esUDP)
            {
                uint nResultados = reader.ReadUInt32();
                for (uint i = 0; i < nResultados; i++)
                {
                    m_ExtractResult(reader, search);
                }
                search.OnTCPSearchEnded();
            }
            else
            {
                m_ExtractResult(reader, search);
                while ((reader.PeekChar() != 0) && (reader.PeekChar() != -1))
                {
                    Debug.WriteLine("MoreUDP results in one packet");
                    if ((Protocol.ProtocolType)reader.ReadByte() != Protocol.ProtocolType.eDonkey)
                    {
                        break;
                    }
                    if ((reader.PeekChar() == -1) || (reader.ReadByte() != (byte)Protocol.ServerCommandUDP.GlobalSearchResult))
                    {
                        break;
                    }
                    m_ExtractResult(reader, search);
                }
            }
            reader.Close();
            buffer.Close();
            reader = null;
            buffer = null;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Increase connection fails by reason.
        /// </summary>
        /// <param name="reason">Reason why connection fails.</param>
        /// <returns>New fails count.</returns>
        public uint IncFails(byte reason)
        {
            if (CKernel.ServersList.ConnectionFailed(this, reason))
            {
                string strreason = "";
                switch ((Protocol.ConnectionReason)reason)
                {
                case Protocol.ConnectionReason.CannotConnect:
                    strreason = CKernel.Globalization["SRV_DOWN"];
                    break;

                case Protocol.ConnectionReason.ClosedConnection:
                    strreason = CKernel.Globalization["SRV_DISCONNECTED"];
                    break;

                case Protocol.ConnectionReason.NullPacket:
                    strreason = CKernel.Globalization["SRV_FULL"];
                    break;

                case Protocol.ConnectionReason.NullID:
                    strreason = CKernel.Globalization["SRV_FULL"];                           //strreason="ID 0";
                    break;

                case Protocol.ConnectionReason.InvalidHeader:
                    strreason = CKernel.Globalization["SRV_FULL"];                           //strreason="Invalid header";
                    break;
                }
                CLog.Log(Constants.Log.Info, "SRV_NOTCONNECT", this.Name, strreason);
                if (reason == (byte)Protocol.ConnectionReason.CannotConnect)
                {
                    m_nFails++;
                }
            }
            m_ServerConnection       = null;
            m_AllFilesPublished      = false;
            m_LastPublishedTime      = DateTime.MinValue;
            m_LastFilePublishedIndex = 0;
            if (m_LastSearcher != null)
            {
                m_LastSearcher.OnTCPSearchEnded();
            }
            return(m_nFails);
        }
Ejemplo n.º 3
0
 public CServerSearchResults(MemoryStream buffer,CSearcher search,bool esUDP)
 {
     BinaryReader reader=new BinaryReader(buffer);
     if (!esUDP)
     {
         uint nResultados=reader.ReadUInt32();
         for (uint i=0;i<nResultados;i++)
         {
             m_ExtractResult(reader,search);
         }
         search.OnTCPSearchEnded();
     }
     else
     {
         m_ExtractResult(reader,search);
         while ((reader.PeekChar()!=0)&&(reader.PeekChar()!=-1))
         {
             Debug.WriteLine("MoreUDP results in one packet");
             if ((Protocol.ProtocolType)reader.ReadByte() != Protocol.ProtocolType.eDonkey) break;
             if ((reader.PeekChar()==-1)||(reader.ReadByte() != (byte)Protocol.ServerCommandUDP.GlobalSearchResult))
                 break;
             m_ExtractResult(reader,search);
         }
     }
     reader.Close();
     buffer.Close();
     reader=null;
     buffer=null;
 }