Ejemplo n.º 1
0
        public void Init(object initData, System.Action <string, bool> callback)
        {
            mLoggedIn     = SecurePrefs.GetInt("DeviceLoggedIn", 0) > 0;
            mDeviceAuthId = SecurePrefs.GetString("DeviceAuthId", Device.UniqueIdentifier);

            callback(null, true);
        }
Ejemplo n.º 2
0
        public void Authenticate(bool silent, System.Action <string, object> callback)
        {
            if (silent)
            {
                if (mLoggedIn)
                {
                    var data = Johny.HashtablePool.Claim();
                    data["udid"] = mDeviceAuthId;
                    callback(null, data);
                }
                else
                {
                    callback(null, null);
                }
            }
            else
            {
                mLoggedIn = true;

                SecurePrefs.SetInt("DeviceLoggedIn", EB.Time.Now);
                SecurePrefs.SetString("DeviceAuthId", mDeviceAuthId);

                var data = Johny.HashtablePool.Claim();
                data["udid"] = mDeviceAuthId;
                callback(null, data);
            }
        }
Ejemplo n.º 3
0
        public void OnAsLogin(string token)
        {
            EB.Debug.Log("OnAsLogin token = {0} ", token);

            if (!string.IsNullOrEmpty(token))
            {
                mIsLoggedIn = true;
                SecurePrefs.SetInt("AsUid", int.Parse(pxAsUserID()));

                if (mLoginCallBack != null)
                {
                    Hashtable auth = new Hashtable();
                    auth["token"] = token;
                    mLoginCallBack(null, auth);
                    mLoginCallBack = null;
                }
            }
            else
            {
                if (mLoginCallBack != null)
                {
                    mLoginCallBack("LoginFailed", null);
                    mLoginCallBack = null;
                }
            }
        }
Ejemplo n.º 4
0
        static public void SaveAccountData(string phone, string password)
        {
            UserInfo userInfo = UserInfoList.Find(u => u.phone == phone);

            if (userInfo == null)
            {
                UserInfoList.Add(new UserInfo()
                {
                    phone    = phone,
                    password = password
                });
            }
            else
            {
                userInfo.password = password;
            }
            SecurePrefs.SetString("UserID", phone);
            SecurePrefs.SetString("UserPwd", password);

            string userInfos = SecurePrefs.GetString("UserInfoData", "");

            Debug.Log("store before UserInfoData:" + userInfos);
            Hashtable userHashtable = EB.JSON.Parse(userInfos) as Hashtable;

            if (userHashtable != null && userHashtable.ContainsKey(phone))
            {
                userHashtable.Remove(phone);
            }
            userHashtable = userHashtable ?? Johny.HashtablePool.Claim();
            userHashtable.Add(phone, password);
            SecurePrefs.SetString("UserInfoData", EB.JSON.Stringify(userHashtable));
            Debug.Log("store UserInfoData:" + SecurePrefs.GetString("UserInfoData", ""));
        }
Ejemplo n.º 5
0
        public void InitSDK(object options, System.Action <string, bool> callback)
        {
#if UNITY_EDITOR
            mIsInited   = false;
            mIsLoggedIn = false;
            callback(null, mIsInited);
#elif UNITY_IPHONE
            if (mIsInited)
            {
                callback(null, true);
            }
            else
            {
                new GameObject("as_callback", typeof(SparxAsSDKManager));

                //int appId = Dot.Integer("appId", options, 2241);
                //string appKey = Dot.String("appKey", options, "9d5e83cf5653400b959cd03c422579c6");
                int    appId  = Dot.Integer("appId", options, 2356);
                string appKey = Dot.String("appKey", options, "2cd489c773204183af5c30c44360501e");
                pxAsInit(appId, appKey);
                mIsInited   = true;
                mIsLoggedIn = SecurePrefs.GetInt("AsUid", 0) > 0;
                callback(null, mIsInited);
            }
#else
            mIsInited   = false;
            mIsLoggedIn = false;
            callback(null, mIsInited);
#endif
        }
Ejemplo n.º 6
0
        private void OnSubmit(string accountId)
        {
#if USE_ACCOUNT_AUTH
            EB.Debug.Log("OnSubmit: accountId = {0}", accountId);

            if (string.IsNullOrEmpty(accountId))
            {
                if (mAuthCallback != null)
                {
                    mAuthCallback("Empty Account Id!", null);
                    mAuthCallback = null;
                }
            }
            else
            {
                if (mAuthCallback != null)
                {
                    mLoggedIn  = true;
                    mAccountId = accountId;
                    SecurePrefs.SetString("AccountId", mAccountId);

                    var data = new Hashtable();
                    data["accountId"] = mAccountId;
                    mAuthCallback(null, data);
                    mAuthCallback = null;
                }
            }
#endif
        }
Ejemplo n.º 7
0
 public void Save(string key)
 {
     // save fragments as it will be faster
     //var r =
     SecurePrefs.SetJSON(key, fragments);
     //Debug.Log("Save Offline: \n" + r);
 }
Ejemplo n.º 8
0
        public string GetPlatform()
        {
            string lastPlatform = SecurePrefs.GetString("TencentPlatform", null);

            EB.Debug.Log("GetPlatform: lastPlatform = {0}", lastPlatform);
            return(lastPlatform);
        }
Ejemplo n.º 9
0
        public void Load(string key)
        {
            var data = SecurePrefs.GetJSON(key);

            if (data != null && data is Hashtable)
            {
                StoreResult((Hashtable)data, true);
            }
        }
Ejemplo n.º 10
0
 public void Logout()
 {
     if (mLoggedIn)
     {
         SecurePrefs.DeleteKey("DeviceLoggedIn");
         mLoggedIn     = false;
         mDeviceAuthId = string.Empty;
     }
 }
Ejemplo n.º 11
0
        public void Logout()
        {
#if USE_ACCOUNT_AUTH
            if (mLoggedIn)
            {
                mLoggedIn  = false;
                mAccountId = string.Empty;
                SecurePrefs.DeleteKey("AccountId");
            }
#endif
        }
Ejemplo n.º 12
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽数据操作∽-★-∽--------∽-★-∽------∽-★-∽--------//

        //-------∽-★-∽------∽-★-∽--------∽-★-∽SETTER∽-★-∽--------∽-★-∽------∽-★-∽--------//

        /// <summary>
        /// 设置字符串
        /// </summary>
        /// <param name="key_"></param>
        /// <param name="value_"></param>
        public void SetString(string key_, string value_)
        {
            if (value_ != null)
            {
                key_ = TransKey(key_);
                SecurePrefs.SetString(key_, value_);
            }
            else
            {
                DeleteKey(key_);
            }
        }
Ejemplo n.º 13
0
        public void Logout()
        {
            if (!mIsInited)
            {
                return;
            }

            if (IsLoggedIn())
            {
                EB.Debug.Log("AsSDKManager.Logout");
                mIsLoggedIn = false;
                SecurePrefs.DeleteKey("AsUid");
                pxAsLogout();
            }
        }
Ejemplo n.º 14
0
        public void Init(object initData, System.Action <string, bool> callback)
        {
#if USE_ACCOUNT_AUTH
            mAccountId = SecurePrefs.GetString("AccountId", mAccountId);
            if (mLoginUI == null)
            {
                mLoginUI = new GameObject("account_auth_ui", typeof(SparxAccountAuthenticator));
                mLoginUI.SetActive(false);
                var comp = mLoginUI.GetComponent <SparxAccountAuthenticator>();
                comp.SetInput(mAccountId);
                comp.OnSubmit += OnSubmit;
            }

            callback(null, true);
#else
            callback(null, false);
#endif
        }
Ejemplo n.º 15
0
        public void Init(object initData, System.Action <string, bool> callback)
        {
            UserInfoList = new List <UserInfo>();
            string userInfos = SecurePrefs.GetString("UserInfoData", "");

            EB.Debug.Log("Manhuang:" + userInfos);
            Hashtable userHashtable = EB.JSON.Parse(userInfos) as Hashtable;

            if (userHashtable != null && userHashtable.Count > 0)
            {
                foreach (DictionaryEntry user in userHashtable)
                {
                    UserInfoList.Add(new UserInfo()
                    {
                        phone    = user.Key.ToString(),
                        password = user.Value.ToString()
                    });
                    EB.Debug.Log("Manhuang_Login:{" + user.Key.ToString() + "," + user.Value.ToString() + "}");
                }
            }
            callback(null, true);
        }
Ejemplo n.º 16
0
        public void Authenticate(bool silent, System.Action <string, object> callback)
        {
            if (silent)
            {
                if (IsLoggedIn)
                {
                    callback(null, Johny.HashtablePool.Claim());
                    return;
                }
                else
                {
                    callback(null, null);
                    return;
                }
            }
            else
            {
                System.Action <string, string, string, string> cb = delegate(string phone, string openId, string accessToken, string password) {
                    var data = Johny.HashtablePool.Claim();
                    Debug.Log("MHAuthenticator callback openId:{0} accessToken:{1}", openId, accessToken);
                    data["openId"]      = openId;
                    data["accessToken"] = accessToken;
                    callback(null, data);
                    mLoggedIn = true;
                    UserPhone = phone;
                    SaveAccountData(phone, password);
                };

                string userID  = SecurePrefs.GetString("UserID", string.Empty);
                string userPwd = SecurePrefs.GetString("UserPwd", string.Empty);

                SparxHub.Instance.Config.LoginConfig.Listener.OnMHLogin(new Hashtable()
                {
                    { "userID", userID }, { "password", userPwd }, { "callback", cb }
                });
            }
        }
Ejemplo n.º 17
0
 public void DeletePlatform()
 {
     EB.Debug.Log("DeletePlatform");
     SecurePrefs.DeleteKey("TencentPlatform");
 }
Ejemplo n.º 18
0
 public void DeleteKey(string key_)
 {
     key_ = TransKey(key_);
     SecurePrefs.DeleteKey(key_);
 }
Ejemplo n.º 19
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽数据管理∽-★-∽--------∽-★-∽------∽-★-∽--------//

        public bool HasKey(string key_)
        {
            key_ = TransKey(key_);
            return(SecurePrefs.HasKey(key_));
        }
Ejemplo n.º 20
0
 public string GetString(string key_, string defaultValue_ = null)
 {
     key_ = TransKey(key_);
     return(SecurePrefs.GetString(key_, defaultValue_));
 }
Ejemplo n.º 21
0
 public int GetInt(string key_, int defaultValue_ = 0)
 {
     key_ = TransKey(key_);
     return(SecurePrefs.GetInt(key_, defaultValue_));
 }
Ejemplo n.º 22
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽GETTER∽-★-∽--------∽-★-∽------∽-★-∽--------//


        public float GetFloat(string key_, float defaultValue_ = 0)
        {
            key_ = TransKey(key_);
            return(SecurePrefs.GetFloat(key_, defaultValue_));
        }
Ejemplo n.º 23
0
 /// <summary>
 /// 设置浮点型
 /// </summary>
 /// <param name="key_"></param>
 /// <param name="value_"></param>
 public void SetFloat(string key_, float value_)
 {
     key_ = TransKey(key_);
     SecurePrefs.SetFloat(key_, value_);
 }
Ejemplo n.º 24
0
 /// <summary>
 /// 设置整型
 /// </summary>
 /// <param name="key_"></param>
 /// <param name="value_"></param>
 public void SetInt(string key_, int value_)
 {
     key_ = TransKey(key_);
     SecurePrefs.SetInt(key_, value_);
 }
Ejemplo n.º 25
0
 public void Save(string key)
 {
     SecurePrefs.SetJSON(key, ToHashtable());
 }
Ejemplo n.º 26
0
 public void Load(string key)
 {
     Update(SecurePrefs.GetJSON(key));
 }
Ejemplo n.º 27
0
 public void SavePlatform(string platform)
 {
     EB.Debug.Log("SavePlatform: platform = {0}", platform);
     SecurePrefs.SetString("TencentPlatform", platform);
 }