Beispiel #1
0
    void OnFinishRequest(HTTPRequest request, HTTPResponse response)
    {
        if (response != null)
        {
            string info = response.DataAsText;
            if (!string.IsNullOrEmpty(info))
            {
                //string info = System.IO.File.ReadAllText(Application.dataPath + "/_VerInfo/VerInfo.txt",System.Text.Encoding.UTF8);
                VerInfoList verInfo = JsonUtility.FromJson <VerInfoList>(response.DataAsText);
                foreach (var item in verInfo.list)
                {
                    VerInfo infoNew = new VerInfo(item.SocketIp, item.Port, item.Ver);
                    if (_dicVerInfo.ContainsKey(infoNew.Ver))
                    {
                        _dicVerInfo[infoNew.Ver] = infoNew;
                    }
                    else
                    {
                        _dicVerInfo.Add(infoNew.Ver, infoNew);
                    }
                }

                if (OnCallBack != null)
                {
                    OnCallBack(true);
                }

                return;
            }
        }


        Debug.LogError("网络连接出错,配置信息无法获取");

        if (OnCallBack != null)
        {
            OnCallBack(false);
        }

//		System.IO.StringReader sr = new System.IO.StringReader(response.DataAsText);
//		if(sr != null)
//		{
//			string lineTxt = sr.ReadLine();
//			while(!string.IsNullOrEmpty(lineTxt))
//			{
//				Debug.Log("line:" + lineTxt);
//
//				lineTxt = sr.ReadLine();
//			}
//
//			sr.Close();
//		}
//
//		string info = System.IO.File.ReadAllText(Application.dataPath + "/_VerInfo/VerInfo.txt",System.Text.Encoding.UTF8);
//		VerInfoList verInfo = JsonUtility.FromJson<VerInfoList>(info);
//		foreach(var item in verInfo.list)
//		{
//			Debug.Log(item.SocketIp + "," + item.Ver);
//		}
    }
Beispiel #2
0
    private static void CreateInfo()
    {
        VerInfoList listInfo = new VerInfoList();

        VerInfo info = new VerInfo("116.228.88.149", 5555, "1.0");

        listInfo.list.Add(info);

        info = new VerInfo("192.168.10.28", 5555, "1.1");
        listInfo.list.Add(info);

        info = new VerInfo("games.emagroup.cn", 5555, "99");
        listInfo.list.Add(info);

        string jsonInfo = JsonUtility.ToJson(listInfo);

        System.IO.File.WriteAllText(Application.dataPath + "/_VerInfo/VerInfo.txt", jsonInfo);
        Debug.Log("生成配置文件成功");
        AssetDatabase.Refresh();

//		PlayerSettings.bundleVersion
    }