//-------------------------------------------------------------------------------------------------------
    public void onSocketConnect(bool result)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("LoginScript_hotfix", "onSocketConnect"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.LoginScript_hotfix", "onSocketConnect", null, result);
            return;
        }

        NetLoading.getInstance().Close();

        if (result)
        {
            //LogUtil.Log("连接服务器成功");

            NetLoading.getInstance().Close();
            NetErrorPanelScript.getInstance().Close();

            // 检查版本号
            reqCheckVerisionCode();
        }
        else
        {
            //LogUtil.Log("连接服务器失败,尝试重新连接");

            NetErrorPanelScript.getInstance().Show();
            NetErrorPanelScript.getInstance().setOnClickButton(onClickChongLian);
            NetErrorPanelScript.getInstance().setContentText("连接服务器失败,请重新连接");
        }
    }
    public void onReceive_CheckVerisionCode(string data)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("LoginScript_hotfix", "onReceive_CheckVerisionCode"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.LoginScript_hotfix", "onReceive_CheckVerisionCode", null, data);
            return;
        }

        NetLoading.getInstance().Close();

        JsonData jd   = JsonMapper.ToObject(data);
        int      code = (int)jd["code"];

        if (code == (int)TLJCommon.Consts.Code.Code_OK)
        {
            bool isStopServer = (bool)jd["isStopServer"];
            if (isStopServer)
            {
                NetErrorPanelScript.getInstance().Show();
                NetErrorPanelScript.getInstance().setOnClickButton(onServerIsStop);
                NetErrorPanelScript.getInstance().setContentText("服务器正在维护,请稍后登录。");

                return;
            }

            OtherData.s_canRecharge = (bool)jd["canRecharge"];
            OtherData.s_canDebug    = (bool)jd["canDebug"];

            string apkVersion = jd["apkVersion"].ToString();

            if (OtherData.s_apkVersion.CompareTo(apkVersion) < 0)
            {
                NetErrorPanelScript.getInstance().Show();
                NetErrorPanelScript.getInstance().setOnClickButton(onApkVerisionIsLow);
                NetErrorPanelScript.getInstance().setContentText("您的客户端版本过低,请更新到最新版本。");
            }

            //// 代码版本
            //{
            //    m_codeVersion = (int)jd["codeVersion"];

            //    NetLoading.getInstance().Show();
            //    ILRuntimeUtil.getInstance().downDll(OtherData.getWebUrl() + "hotfix/HotFix_Project-" + m_codeVersion + ".dll");
            //}

            {
                string banbao = jd["banhao"].ToString();
                PlayerPrefs.SetString("banhao", banbao);
            }
        }
        else
        {
            NetErrorPanelScript.getInstance().Show();
            NetErrorPanelScript.getInstance().setOnClickButton(reqCheckVerisionCode);
            NetErrorPanelScript.getInstance().setContentText("服务器内部错误");
        }
    }
        public static void onReceive_CheckVerisionCode(string data)
        {
            LoginScript script = OtherData.s_loginScript;

            NetLoading.getInstance().Close();

            JsonData jd   = JsonMapper.ToObject(data);
            int      code = (int)jd["code"];

            if (code == (int)TLJCommon.Consts.Code.Code_OK)
            {
                bool isStopServer = (bool)jd["isStopServer"];
                if (isStopServer)
                {
                    NetErrorPanelScript.getInstance().Show();
                    NetErrorPanelScript.getInstance().setOnClickButton(onServerIsStop);
                    NetErrorPanelScript.getInstance().setContentText("服务器正在维护,请稍后登录。");

                    return;
                }

                OtherData.s_canRecharge = (bool)jd["canRecharge"];
                OtherData.s_canDebug    = (bool)jd["canDebug"];

                string apkVersion = jd["apkVersion"].ToString();

                if (OtherData.s_apkVersion.CompareTo(apkVersion) < 0)
                {
                    // ios的暂时不做版本检测
                    //if (OtherData.s_channelName.CompareTo("ios") == 0)
                    //{

                    //}
                    // 评测包不做版本检测
                    if (OtherData.s_channelName.CompareTo("javgame_test") == 0)
                    {
                    }
                    else
                    {
                        NetErrorPanelScript.getInstance().Show();
                        NetErrorPanelScript.getInstance().setOnClickButton(onApkVerisionIsLow);
                        NetErrorPanelScript.getInstance().setContentText("您的客户端版本过低,请更新到最新版本。");
                    }
                }

                {
                    string banbao = jd["banhao"].ToString();
                    PlayerPrefs.SetString("banhao", banbao);
                }
            }
            else
            {
                ToastScript.createToast("服务器内部错误");
            }
        }
    public void onServerIsStop()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("LoginScript_hotfix", "onServerIsStop"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.LoginScript_hotfix", "onServerIsStop", null, null);
            return;
        }

        NetErrorPanelScript.getInstance().Show();
        NetErrorPanelScript.getInstance().setOnClickButton(onServerIsStop);
        NetErrorPanelScript.getInstance().setContentText("服务器正在维护,请稍后登录。");
    }
    public void onClick_retryGetNetFile()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("GetNetEntityFile_hotfix", "onClick_retryGetNetFile"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.GetNetEntityFile_hotfix", "onClick_retryGetNetFile", null, null);
            return;
        }

        NetErrorPanelScript.getInstance().Close();

        getNetFile();
    }
    // 点击网络断开弹框中的重连按钮
    public void onClickChongLian()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("LoginScript_hotfix", "onClickChongLian"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.LoginScript_hotfix", "onClickChongLian", null, null);
            return;
        }

        NetLoading.getInstance().Show();
        NetErrorPanelScript.getInstance().Close();
        LoginServiceSocket.s_instance.startConnect();
    }
    public static NetErrorPanelScript getInstance()
    {
        if (s_instance == null)
        {
            GameObject prefab = Resources.Load("Prefabs/Commons/NetErrorUtil") as GameObject;
            GameObject obj    = GameObject.Instantiate(prefab);

            DontDestroyOnLoad(obj);

            s_instance = obj.GetComponent <NetErrorPanelScript>();
        }

        return(s_instance);
    }
    public void onSocketStop()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("LoginScript_hotfix", "onSocketStop"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.LoginScript_hotfix", "onSocketStop", null, null);
            return;
        }

        //LogUtil.Log("主动与服务器断开连接");

        NetErrorPanelScript.getInstance().Show();
        NetErrorPanelScript.getInstance().setOnClickButton(onClickChongLian);
        NetErrorPanelScript.getInstance().setContentText("与服务器断开连接,请重新连接");
    }
    public void onInvoke()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("GetNetEntityFile_hotfix", "onInvoke"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.GetNetEntityFile_hotfix", "onInvoke", null, null);
            return;
        }

        NetLoading.getInstance().Close();

        NetErrorPanelScript.getInstance().Show();
        NetErrorPanelScript.getInstance().setOnClickButton(onClick_retryGetNetFile);
        NetErrorPanelScript.getInstance().setContentText("获取配置文件超时,请重新获取");
    }
    IEnumerator LoadHotFixAssembly(string url)
    {
        WWW www = new WWW(url);

        while (!www.isDone)
        {
            yield return(null);
        }

        try
        {
            if (!string.IsNullOrEmpty(www.error))
            {
                UnityEngine.Debug.LogError(www.error);
            }

            byte[] dll = www.bytes;
            www.Dispose();

            if (!Directory.Exists(Path.GetDirectoryName(fileInfoPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(fileInfoPath));
            }
            using (System.IO.MemoryStream ms = new MemoryStream(dll))
            {
                using (FileStream fs = new FileStream(fileInfoPath, FileMode.Create))
                {
                    s_appdomain.LoadAssembly(ms, null, new Mono.Cecil.Pdb.PdbReaderProvider());
                    fs.Write(dll, 0, dll.Length);
                    PlayerPrefs.SetString("dllVersion", url);
                }
            }

            InitializeILRuntime();
            OnHotFixLoaded();
        }
        catch (Exception ex)
        {
            LogUtil.Log("LoadHotFixAssembly异常:" + ex);

            NetLoading.getInstance().Close();

            NetErrorPanelScript.getInstance().Show();
            NetErrorPanelScript.getInstance().setOnClickButton(onClickDownDll);
            NetErrorPanelScript.getInstance().setContentText("获取文件失败,请重新获取");
        }
    }
    // 检测服务器是否连接
    public void checkNet()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("LoginScript_hotfix", "checkNet"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.LoginScript_hotfix", "checkNet", null, null);
            return;
        }

        if (!LoginServiceSocket.s_instance.isConnecion())
        {
            //ToastScript.createToast("与Logic服务器断开连接");
            NetErrorPanelScript.getInstance().Show();
            NetErrorPanelScript.getInstance().setOnClickButton(onClickChongLian);
            NetErrorPanelScript.getInstance().setContentText("与服务器断开连接,请重新连接");
        }
    }
 public static void onApkVerisionIsLow()
 {
     if (OtherData.s_channelName.CompareTo("ios") != 0)
     {
         PlatformHelper.DownApk();
         GameObject go = GameObject.Find("NetErrorPanel(Clone)");
         if (go != null)
         {
             GameObject.Destroy(go);
         }
     }
     else
     {
         NetErrorPanelScript.getInstance().Show();
         NetErrorPanelScript.getInstance().setOnClickButton(onApkVerisionIsLow);
         NetErrorPanelScript.getInstance().setContentText("您的客户端版本过低,请更新到最新版本。");
     }
 }
Exemple #13
0
    public void onInvoke_timeout()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("HeartBeat_Play_hotfix", "onInvoke_timeout"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.HeartBeat_Play_hotfix", "onInvoke_timeout", null, null);
            return;
        }

        if (OtherData.s_gameScript != null)
        {
            Destroy(PlayServiceSocket.s_instance.gameObject);

            NetErrorPanelScript.getInstance().Show();
            NetErrorPanelScript.getInstance().setOnClickButton(OtherData.s_gameScript.exitRoom);
            NetErrorPanelScript.getInstance().setContentText("与服务器通讯异常,点击确认回到主界面");
        }
    }
    public void GetFileFail(string fileName)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("GetNetEntityFile_hotfix", "GetFileFail"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.GetNetEntityFile_hotfix", "GetFileFail", null, fileName);
            return;
        }

        {
            for (int i = 0; i < m_fileList.Count; i++)
            {
                if (m_fileList[i].m_fileName.CompareTo(fileName) == 0)
                {
                    m_fileList[i].m_fileGetState = FileInfo.FileGetState.FileGetState_GetFail;
                    break;
                }
            }
        }

        {
            bool hasAllEnd = true;
            for (int i = 0; i < m_fileList.Count; i++)
            {
                if (m_fileList[i].m_fileGetState == FileInfo.FileGetState.FileGetState_NoStart)
                {
                    hasAllEnd = false;
                    break;
                }
            }

            // 全部获取完毕:有成功的有失败的
            if (hasAllEnd)
            {
                NetLoading.getInstance().Close();

                NetErrorPanelScript.getInstance().Show();
                NetErrorPanelScript.getInstance().setOnClickButton(onClick_retryGetNetFile);
                NetErrorPanelScript.getInstance().setContentText("获取配置文件失败,请重新获取");

                CancelInvoke("onInvoke");
            }
        }
    }
    public void onApkVerisionIsLow()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("LoginScript_hotfix", "onApkVerisionIsLow"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.LoginScript_hotfix", "onApkVerisionIsLow", null, null);
            return;
        }

#if UNITY_ANDROID
        PlatformHelper.DownApk();
        GameObject go = GameObject.Find("NetErrorPanel(Clone)");
        if (go != null)
        {
            Destroy(go);
        }
#else
        NetErrorPanelScript.getInstance().Show();
        NetErrorPanelScript.getInstance().setOnClickButton(onApkVerisionIsLow);
        NetErrorPanelScript.getInstance().setContentText("您的客户端版本过低,请更新到最新版本。");
#endif
    }
        public static void Start()
        {
            // 新增的
            {
                if (ShieldShare.isShield(OtherData.s_channelName))
                {
                    OtherData.s_mainScript.gameObject.transform.Find("ButtonList/Share").localScale = Vector3.zero;
                }

                if (ShieldWeChat.isShield(OtherData.s_channelName))
                {
                    // 主界面客服按钮
                    OtherData.s_mainScript.gameObject.transform.Find("ButtonList/Kefu").localScale = Vector3.zero;
                }

                // ios审核
                if (OtherData_hotfix.getIsIosCheck())
                {
                    // 转盘
                    OtherData.s_mainScript.gameObject.transform.Find("ButtonList/Button_zhuanpan").localScale = Vector3.zero;

                    // 签到
                    OtherData.s_mainScript.gameObject.transform.Find("ButtonList/Sign").localScale = Vector3.zero;

                    // 徽章兑换
                    OtherData.s_mainScript.gameObject.transform.Find("UserInfo/Medal/Button_medal_duihuan").localScale = Vector3.zero;

                    // 推广有礼
                    OtherData.s_mainScript.gameObject.transform.Find("ButtonList/TuiGuangYouLi").localScale = Vector3.zero;

                    // 活动
                    OtherData.s_mainScript.gameObject.transform.Find("ButtonList/Notice").localScale = Vector3.zero;
                }
            }

            // 禁止多点触摸
            Input.multiTouchEnabled = false;

            ToastScript.clear();

            // 安卓回调
            AndroidCallBack.s_onPauseCallBack  = OtherData.s_mainScript.onPauseCallBack;
            AndroidCallBack.s_onResumeCallBack = OtherData.s_mainScript.onResumeCallBack;

            AudioScript.getAudioScript().stopMusic();

            OtherData.s_mainScript.startBgm();

            // 逻辑服务器
            {
                if (OtherData.s_mainScript.getLogicEnginerObj() == null)
                {
                    OtherData.s_mainScript.setLogicEnginerObj(LogicEnginerScript.create());
                    LogicEnginerScript.Instance.setOnLogicService_Connect(OtherData.s_mainScript.onSocketConnect_Logic);
                    LogicEnginerScript.Instance.setOnLogicService_Close(OtherData.s_mainScript.onSocketClose_Logic);
                    LogicEnginerScript.Instance.GetComponent <MainRequest>().CallBack = OtherData.s_mainScript.onReceive_Main;
                }
                else
                {
                    LogicEnginerScript.Instance.setOnLogicService_Connect(OtherData.s_mainScript.onSocketConnect_Logic);
                    LogicEnginerScript.Instance.setOnLogicService_Close(OtherData.s_mainScript.onSocketClose_Logic);

                    LogicEnginerScript.Instance.GetComponent <MainRequest>().CallBack = OtherData.s_mainScript.onReceive_Main;

                    if (LogicEnginerScript.Instance.isConnecion())
                    {
                        NetLoading.getInstance().Show();

                        LogicEnginerScript.Instance.GetComponent <GetUserInfoRequest>().OnRequest();
                        LogicEnginerScript.Instance.GetComponent <GetRankRequest>().OnRequest();
                        LogicEnginerScript.Instance.GetComponent <GetSignRecordRequest>().OnRequest();
                        LogicEnginerScript.Instance.GetComponent <GetUserBagRequest>().CallBack = onReceive_GetUserBag;
                        LogicEnginerScript.Instance.GetComponent <GetUserBagRequest>().OnRequest();
                        LogicEnginerScript.Instance.GetComponent <GetEmailRequest>().OnRequest();
                        LogicEnginerScript.Instance.GetComponent <GetNoticeRequest>().OnRequest();
                    }
                    else
                    {
                        NetErrorPanelScript.getInstance().Show();
                        NetErrorPanelScript.getInstance().setOnClickButton(OtherData.s_mainScript.onClickChongLian_Logic);
                        NetErrorPanelScript.getInstance().setContentText("与服务器断开连接,请重新连接");
                    }
                }
            }

            // 游戏打牌服务器
            {
                if (OtherData.s_mainScript.getPlayEnginerObj() == null)
                {
                    OtherData.s_mainScript.setPlayEnginerObj(PlayServiceSocket.create());

                    PlayServiceSocket.s_instance.setOnPlayService_Connect(OtherData.s_mainScript.onSocketConnect_Play);
                    PlayServiceSocket.s_instance.setOnPlayService_Receive(OtherData.s_mainScript.onSocketReceive_Play);
                    PlayServiceSocket.s_instance.setOnPlayService_Close(OtherData.s_mainScript.onSocketClose_Play);

                    PlayServiceSocket.s_instance.startConnect();
                }
                else
                {
                    PlayServiceSocket.s_instance.setOnPlayService_Connect(OtherData.s_mainScript.onSocketConnect_Play);
                    PlayServiceSocket.s_instance.setOnPlayService_Receive(OtherData.s_mainScript.onSocketReceive_Play);
                    PlayServiceSocket.s_instance.setOnPlayService_Close(OtherData.s_mainScript.onSocketClose_Play);
                }
            }

            OtherData.s_mainScript.m_laBaScript = OtherData.s_mainScript.m_laba.GetComponent <LaBaScript>();
        }
 public static void onServerIsStop()
 {
     NetErrorPanelScript.getInstance().Show();
     NetErrorPanelScript.getInstance().setOnClickButton(onServerIsStop);
     NetErrorPanelScript.getInstance().setContentText("服务器正在维护,请稍后登录。");
 }