Esempio n. 1
0
    protected override void Awake()
    {
        base.Awake();
        Object.DontDestroyOnLoad(this);
        CrashlyticsReporter.EnableReport();
        this.defaultScreenWidth = Screen.get_width();
        defaultScreenHeight     = Screen.get_height();
        if (this.defaultScreenWidth > defaultScreenHeight)
        {
            int defaultScreenWidth = this.defaultScreenWidth;
            this.defaultScreenWidth = defaultScreenHeight;
            defaultScreenHeight     = defaultScreenWidth;
        }
        SetupScreen();
        UpdateResolution(Screen.get_width() < Screen.get_height());
        TitleTop.isFirstBoot = true;
        GC.Collect();
        long totalMemory = GC.GetTotalMemory(false);
        int  num         = (int)(52428800 - totalMemory);
        int  num2        = Mathf.Max(num / 1024, 1);

        object[] array = new object[1024];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = new byte[num2];
        }
        array = null;
        GC.Collect();
    }
Esempio n. 2
0
    private void SetUserInfo(UserInfo user_info)
    {
        LoadFavoriteStamp();
        userInfo = user_info;
        CrashlyticsReporter.SetUserInfo(user_info);
        MonoBehaviourSingleton <GoWrapManager> .I.setGUID(user_info.code);

        DirtyUserInfo();
    }
    private IEnumerator Request_Impl <T>(string path, WWWForm form, Action <T> call_back, Action call_fatal, string get_param = "", string token = "") where T : BaseModel, new()
    {
        SetPreload(false);
        if (form == null)
        {
            form = new WWWForm();
        }
        form.AddField("app", "rob");
        if (!string.IsNullOrEmpty(token))
        {
            form.AddField("rcToken", token);
        }
        string url = GetUrl(path, get_param);

        CrashlyticsReporter.SetAPIRequest(url);
        CrashlyticsReporter.SetAPIRequestStatus(true);
        byte[] data = form.get_data();
        Dictionary <string, string> headers = GetHeader(form);
        string msg = GenerateErrorMsg(Error.Unknown);

        AccountManager.Account account = MonoBehaviourSingleton <AccountManager> .I.account;
        lastRequestTime = Time.get_time();
        WWW www = new WWW(url, data, headers);

        try
        {
            WWWInfo wwwinfo = new WWWInfo(www, false, false);
            wwwInfos.Add(wwwinfo);
            DateTime timeBegin = DateTime.Now;
            while (true)
            {
                yield return((object)new WaitForEndOfFrame());

                if ((DateTime.Now - timeBegin).TotalSeconds > 15.0)
                {
                    msg = GenerateErrorMsg(Error.TimeOut);
                    break;
                }
                if (!string.IsNullOrEmpty(www.get_error()))
                {
                    string txt       = www.get_error();
                    int    httpError = 0;
                    msg = ((!int.TryParse(txt.Substring(0, 3), out httpError)) ? GenerateErrorMsg(Error.DetectHttpError) : GenerateErrorMsg((Error)(200000 + httpError)));
                    break;
                }
                if (www.get_isDone())
                {
                    www.get_text();
                    string signature = null;
                    foreach (KeyValuePair <string, string> responseHeader in www.get_responseHeaders())
                    {
                        string headerName = responseHeader.Key.ToLower();
                        if (string.IsNullOrEmpty(tokenTemp) && headerName == "set-cookie")
                        {
                            List <string> values = new List <string>((IEnumerable <string>)responseHeader.Value.Split(';'));
                            foreach (string item in values)
                            {
                                if (item.Contains("robpt"))
                                {
                                    tokenTemp = item;
                                }
                            }
                        }
                        else if (headerName == "x-compress-encrypt")
                        {
                            if (!(responseHeader.Value.Trim() == "cipher"))
                            {
                                continue;
                            }
                        }
                        else if (headerName == "x-signature")
                        {
                            signature = responseHeader.Value.Trim();
                        }
                    }
                    bool   isDecryptSuccess2 = true;
                    byte[] gzippedResponse   = null;
                    try
                    {
                        string key = (!string.IsNullOrEmpty(account.userHash)) ? account.userHash : "ELqdT/y.pM#8+J##x7|3/tLb7jZhmqJ,";
                        gzippedResponse = Cipher.DecryptRJ128Byte(key, "yCNBH$$rCNGvC+#f", www.get_text());
                    }
                    catch (Exception exc4)
                    {
                        Debug.LogException(exc4);
                        Debug.LogError((object)("Decrypt fail: " + www.get_url() + " data " + www.get_text()));
                        Debug.LogError((object)("Key Decrypt : " + ((!string.IsNullOrEmpty(account.userHash)) ? account.userHash : "ELqdT/y.pM#8+J##x7|3/tLb7jZhmqJ,")));
                        isDecryptSuccess2 = false;
                    }
                    if (!isDecryptSuccess2)
                    {
                        if (string.IsNullOrEmpty(account.userHash))
                        {
                            msg = GenerateErrorMsg(Error.DecryptResponceIsNull);
                            Log.Error(LOG.NETWORK, "Decrypt failed!!!");
                            break;
                        }
                        isDecryptSuccess2 = true;
                        try
                        {
                            gzippedResponse = Cipher.DecryptRJ128Byte("ELqdT/y.pM#8+J##x7|3/tLb7jZhmqJ,", "yCNBH$$rCNGvC+#f", www.get_text());
                        }
                        catch (Exception exc3)
                        {
                            Log.Exception(exc3);
                            isDecryptSuccess2 = false;
                        }
                        if (!isDecryptSuccess2)
                        {
                            msg = GenerateErrorMsg(Error.DecryptFailed);
                            Log.Error(LOG.NETWORK, "Decrypt failed");
                            break;
                        }
                    }
                    if (gzippedResponse == null)
                    {
                        msg = GenerateErrorMsg(Error.DecryptResponceIsNull);
                        Log.Error(LOG.NETWORK, "Decrypt responce is null");
                    }
                    else
                    {
                        bool isUncompressSuccess = true;
                        try
                        {
                            msg = GzUncompress(gzippedResponse);
                        }
                        catch (Exception ex)
                        {
                            Exception exc2 = ex;
                            Log.Exception(exc2);
                            isUncompressSuccess = false;
                        }
                        if (!isUncompressSuccess)
                        {
                            msg = GenerateErrorMsg(Error.UncompressFailed);
                        }
                        else if (signature == null)
                        {
                            msg = GenerateErrorMsg(Error.SignatureIsNull);
                            Log.Error(LOG.NETWORK, "Signature is null");
                        }
                        else
                        {
                            bool isVerifySignatureSuccess = true;
                            bool isValidSignature         = true;
                            try
                            {
                                isValidSignature = Cipher.verify(msg, signature);
                            }
                            catch (Exception ex2)
                            {
                                Exception exc = ex2;
                                Log.Exception(exc);
                                isVerifySignatureSuccess = false;
                            }
                            if (!isVerifySignatureSuccess)
                            {
                                msg = GenerateErrorMsg(Error.VerifySignatureFailed);
                            }
                            else if (!isValidSignature)
                            {
                                msg = GenerateErrorMsg(Error.InvalidSignature);
                            }
                            else
                            {
                                msg = Regex.Unescape(msg);
                                if (msg == "{\"error\":0,\"result\":[]}")
                                {
                                    msg = GenerateErrorMsg(Error.EmptyRecord);
                                }
                                if (msg.Contains("\"result\":[]"))
                                {
                                    msg = msg.Replace("\"result\":[]", "\"dummy\":[]");
                                }
                            }
                        }
                    }
                    break;
                }
            }
            wwwInfos.Remove(wwwinfo);
        }
        finally
        {
            ((IDisposable)www)?.Dispose();
        }
        yield return((object)new WaitForEndOfFrame());

        yield return((object)new WaitForEndOfFrame());

        yield return((object)new WaitForEndOfFrame());

        try
        {
            if (call_back != null)
            {
                new T();
                try
                {
                    JSONSerializer.Deserialize <T>(msg);
                }
                catch (Exception ex3)
                {
                    Exception exp2 = ex3;
                    string    decode_failed_msg = GenerateErrorMsg(Error.DecodeFailed);
                    JSONSerializer.Deserialize <T>(decode_failed_msg);
                    Debug.LogException(exp2);
                }
                finally
                {
                    ((_003CRequest_Impl_003Ec__Iterator1E7 <T>) /*Error near IL_08b6: stateMachine*/)._003C_003E__Finally0();
                }
            }
        }
        catch (Exception exp)
        {
            Debug.LogException(exp);
            CrashlyticsReporter.SetAPIRequestStatus(false);
            call_fatal();
        }
    }