Пример #1
0
 void checkUpdates()
 {
     Debug.Log("[AppMng.checkUpdates]开始检查更新");
     PanelTool.InitPanel("hall", "systempop", 1);
     PanelTool.InitPanel("hall", "loading", 1);
     PanelTool.InitPanel("hall", "toast", 1);
     PanelTool.OpenPanel("hall", "checkupdates", 0, null);
 }
Пример #2
0
    public void HttpErr(string _url, string _tip)
    {
        Debug.LogError(_tip + "\n" + _url);
        AppMng.Instance.Restart();
        LuaTable tab = AppMng.luaEnv.NewTable();

        tab.Set("tip", _tip);
        Action yes = () =>
        {
            PanelTool.ClosePanel("hall", "systempop");
        };

        tab.Set("yes_cb", yes);
        PanelTool.OpenPanel("hall", "systempop", 1, tab);
    }
Пример #3
0
    public void Restart()
    {
        CorMng.Instance.Clear();
        HttpSerMng.Instance.Clear();
        EventTool.Clear();
        PanelTool.Clear();

        AudioMng.Instance.Init();

        PanelTool.InitPanel("hall", "systempop", 1);
        PanelTool.InitPanel("hall", "loading", 1);
        PanelTool.InitPanel("hall", "toast", 1);
        LuaTable logindata = luaEnv.NewTable();

        PanelTool.OpenPanel("hall", "login", 0, logindata);
    }
Пример #4
0
    IEnumerator request(string _url, Action <string> _callback, string _json)
    {
        WWWForm   form = new WWWForm();
        Hashtable keys = MiniJSON.jsonDecode(_json) as Hashtable;

        foreach (string k in keys.Keys)
        {
            form.AddField(k, keys[k].ToString());
        }
        byte errCount = 0;

        while (true)
        {
            using (UnityWebRequest uwr = UnityWebRequest.Post(_url, form))
            {
                uwr.downloadHandler = new DownloadHandlerBuffer();
                uwr.timeout         = HttpSerMng.TimeOut;
                yield return(uwr.SendWebRequest());

                if (string.IsNullOrEmpty(uwr.error))
                {
                    if (_callback != null)
                    {
                        Hashtable result = null;
                        try
                        {
                            result = MiniJSON.jsonDecode(uwr.downloadHandler.text) as Hashtable;
                            MiniJSON.jsonEncode(result);
                        }
                        catch
                        {
                            HttpErr(_url, "[HttpSerMng.request]Json解析异常:" + uwr.downloadHandler.text);
                        }

                        if (int.Parse(result["code"].ToString()) == -2)
                        {
                            AppMng.Instance.Restart();
                            LuaTable tab = AppMng.luaEnv.NewTable();
                            tab.Set("tip", result["msg"].ToString());
                            Action yes = () =>
                            {
                                PanelTool.ClosePanel("hall", "systempop");
                            };
                            tab.Set("yes_cb", yes);
                            PanelTool.OpenPanel("hall", "systempop", 1, tab);
                        }
                        else
                        {
                            _callback(uwr.downloadHandler.text);
                        }
                        uwr.Dispose();
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    errCount++;
                    if (errCount > CAN_ERR_COUNT)
                    {
                        HttpErr(_url, "[HttpSerMng.request]请求异常:" + uwr.error);
                        break;
                    }
                }
            }
        }
    }