예제 #1
0
 public static void SetNetAccConfig(bool open)
 {
     if (open)
     {
         NetworkAccelerator.Start();
     }
     else
     {
         NetworkAccelerator.Stop();
     }
     PlayerPrefs.SetInt(NetworkAccelerator.PLAYER_PREF_NET_ACC, (!open) ? 0 : 1);
     PlayerPrefs.Save();
 }
    public static void SetNetAccConfig(bool open)
    {
        if (open)
        {
            NetworkAccelerator.Start();
        }
        else
        {
            NetworkAccelerator.Stop();
        }
        PlayerPrefs.SetInt(NetworkAccelerator.PLAYER_PREF_NET_ACC, open ? 1 : 0);
        PlayerPrefs.Save();
        MonoSingleton <GSDKsys> .GetInstance().StartGSDKSpeed(!open);

        NetworkAccelerator.PrintLog("SetNetAccConfig " + open);
    }
    public static void InitACC(NetworkAccelerator.XunYouMode mode = NetworkAccelerator.XunYouMode.Disable)
    {
        NetworkAccelerator.PrintLog("Begin Network Acc");
        NetworkAccelerator.setSDKMode(mode);
        if (mode == NetworkAccelerator.XunYouMode.Disable)
        {
            NetworkAccelerator.PrintLog("mode " + mode);
            return;
        }
        if (NetworkAccelerator.s_inited)
        {
            NetworkAccelerator.PrintLog("already init");
            NetworkAccelerator.Stop();
            return;
        }
        Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.NetworkAccelerator_TurnOn, new CUIEventManager.OnUIEventHandler(NetworkAccelerator.OnEventTurnOn));

        Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.NetworkAccelerator_Ignore, new CUIEventManager.OnUIEventHandler(NetworkAccelerator.OnEventTurnIgore));

        Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.NetworkAccelerator_WIFI_TurnOn, new CUIEventManager.OnUIEventHandler(NetworkAccelerator.OnEventTurnOnWIFI));

        NetworkAccelerator.PrintLog(string.Concat(new object[]
        {
            "key:",
            NetworkAccelerator.key,
            " mode ",
            mode
        }));
        try
        {
            AndroidJavaObject GMContext = null;
            using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
            {
                GMContext = androidJavaClass.GetStatic <AndroidJavaObject>("currentActivity");
            }
            AndroidJavaClass GMClass = new AndroidJavaClass("com.subao.gamemaster.GameMaster");
            if (GMClass != null)
            {
                GMContext.Call("runOnUiThread", new object[]
                {
                    delegate
                    {
                        int num = GMClass.CallStatic <int>("init", new object[]
                        {
                            GMContext,
                            1,
                            NetworkAccelerator.key,
                            "KingsGlory",
                            "libapollo.so",
                            13001
                        });
                        if (num >= 0)
                        {
                            NetworkAccelerator.PrintLog("Initialize GameMaster Success!");
                            NetworkAccelerator.s_inited = true;
                            NetworkAccelerator.setSDKMode(mode);
                            NetworkAccelerator.SetUserToken();
                            if (MonoSingleton <CTongCaiSys> .GetInstance().IsTongCaiUserAndCanUse())
                            {
                                int freeFlowUser = -1;
                                if (MonoSingleton <CTongCaiSys> .GetInstance().supplierType == IspType.Dianxing)
                                {
                                    freeFlowUser = 2;
                                }
                                else if (MonoSingleton <CTongCaiSys> .GetInstance().supplierType == IspType.Liantong)
                                {
                                    freeFlowUser = 1;
                                }
                                else if (MonoSingleton <CTongCaiSys> .GetInstance().supplierType == IspType.Yidong)
                                {
                                    freeFlowUser = 0;
                                }
                                NetworkAccelerator.setFreeFlowUser(freeFlowUser);
                            }
                            NetworkAccelerator.setGameId(MonoSingleton <TdirMgr> .GetInstance().SelectedTdir.logicWorldID);
                            NetworkAccelerator.ChangeLogLevel(NetworkAccelerator.LOG_LEVEL_ERROR);
                        }
                        else
                        {
                            NetworkAccelerator.PrintLog("Initialize GameMaster Fail!, ret:" + num);
                        }
                    }
                });
            }
        }
        catch (Exception ex)
        {
            NetworkAccelerator.PrintLog("catch ex " + ex.ToString());
        }
    }