예제 #1
0
        public bool Connect()
        {
            m_server = new FreeDBSite("freedb.freedb.org", FreeDBSite.FreeDBProtocol.HTTP, 80, "/~cddb/cddb.cgi",
                                      "N000.00", "W000.00", "Random freedb server");

            m_serverURL = "http://" + m_server.Host + ":" + m_server.Port + m_server.URI;

            return(true);
        }
예제 #2
0
        public async Task <FreeDBSite[]> GetFreedbSitesAsync()
        {
            FreeDBSite[] retval = null;
            // FIXME: Close reader
            StreamReader urlRdr = await GetStreamFromSiteAsync("sites").ConfigureAwait(false);

            m_message = await urlRdr.ReadLineAsync().ConfigureAwait(false);

            int code = GetCode(m_message);

            m_message = m_message.Substring(4); // remove the code...
            char[] sep = { ' ' };

            switch (code)
            {
            case 210: // OK, Site Information Follows.
                // Read in all sites.
                string[] sites = await ParseMultiLineAsync(urlRdr).ConfigureAwait(false);

                retval = new FreeDBSite[sites.Length];
                int index = 0;
                // Loop through server list and extract different parts.
                foreach (string site in sites)
                {
                    string   loc      = "";
                    string[] siteInfo = site.Split(sep);
                    retval[index]           = new FreeDBSite();
                    retval[index].Host      = siteInfo[0];
                    retval[index].Protocol  = (FreeDBSite.FreeDBProtocol)Enum.Parse(typeof(FreeDBSite.FreeDBProtocol), siteInfo[1], true);
                    retval[index].Port      = Convert.ToInt32(siteInfo[2]);
                    retval[index].URI       = siteInfo[3];
                    retval[index].Latitude  = siteInfo[4];
                    retval[index].Longitude = siteInfo[5];

                    for (int i = 6; i < siteInfo.Length; i++)
                    {
                        loc += retval[i] + " ";
                    }
                    retval[index].Location = loc;
                    index++;
                }
                break;

            case 401: // No Site Information Available.
                break;

            default:
                break;
            }
            return(retval);
        }
예제 #3
0
 public bool Connect(FreeDBSite site)
 {
     m_server    = site;
     m_serverURL = "http://" + m_server.Host + ":" + m_server.Port + m_server.URI;
     return(true);
 }