Пример #1
0
    IEnumerator GetServerConfig()
    {
        Debug.Log("start link");
        ///开始连接,获取配置表
        WWW www = new WWW(ComTool.FormatTickUrl(URL_SERVER_CONFIG));

        yield return(www);

        if (www.error == null)
        {
            string      content = www.text;
            XmlDocument xml     = new XmlDocument();
            try
            {
                xml.LoadXml(content);
                Debug.LogError("get xml succsess");
                XmlNode node = null;

                node = xml.SelectSingleNode("root/ChargeType");
                Debug.LogError(" get id : " + node.Attributes.GetNamedItem("id").Value + " desc :" + node.Attributes.GetNamedItem("desc").Value);

                node           = xml.SelectSingleNode("root/AssetUrl");
                URL_SERVER_RES = node.Attributes.GetNamedItem("id").Value;
            }
            catch (Exception e)
            {
                Debug.LogError("xml format error:" + e.ToString());//xml格式错误
            }
            www.Dispose();
        }
        else
        {
            Debug.LogError("Config www net error:" + www.error);//网络请求失败
            //   StartCoroutine(StartCheck());
        }

        //请求非强制资源配置
        if (URL_SERVER_RES != "")
        {
            //获得资源配置表
            WWW wwwXML = new WWW(ComTool.FormatTickUrl(URL_SERVER_RES + URL_SERVER_XML));
            if (wwwXML.error == null)
            {
                string      content = wwwXML.text;
                XmlDocument xml     = new XmlDocument();
                try
                {
                    xml.LoadXml(content);
                    DBVersionManager.SetServerXML(xml);
                    AysnResManager.Instance.SetResUrl(URL_SERVER_RES);
                }
                catch (Exception e)
                {
                    Debug.LogError("unforce xml format error:" + e.ToString());//xml格式错误
                }

                wwwXML.Dispose();
            }
            ///
            yield return(wwwXML);
        }
    }