private void AuthStart(Action onSuccess, Action <WebAPIException> onFailed) { float timeout = GameWebAPI.Instance().GetTimeout(); NpOAuth.Instance.X_AppVer = WebAPIPlatformValue.GetAppVersion(); NpOAuth.Instance.initURL = WebAPIPlatformValue.GetHttpAddressAuth(); NpOAuth.Instance.counsumerKey = WebAPIPlatformValue.GetCounsumerKey(); NpOAuth.Instance.counsumerSecret = WebAPIPlatformValue.GetCounsumerSecret(); NpOAuth.Instance.TimeOut = timeout; NpOAuth.Instance.type = NpOAuthType.Json; Action <NpOAuthErrData> faildAction = delegate(NpOAuthErrData errData) { if (errData.FailedCode != NpOatuhFailedCodeE.ServerFailed) { onFailed(null); } else { WWWResponse request_result = new WWWResponse { responseJson = errData.VenusRespones_.ResJson, errorText = errData.VenusRespones_.Message, errorStatus = WWWResponse.LocalErrorStatus.NONE }; try { GameWebAPI.Instance().GetResponseJson(request_result); } catch (WebAPIException obj) { onFailed(obj); } } }; NpAes aes = new NpAes(); NpOAuth.Instance.Init(this, onSuccess, faildAction, aes); }
private IEnumerator LoadOAuth(MonoBehaviour _behaviour, Action successAction, Action <NpOAuthErrData> faildAction, NpAes aes) { bool isNew = false; string baseUUIDData = PlayerPrefs.GetString("uuid"); if (baseUUIDData.Equals(string.Empty)) { isNew = true; this.uuid = NpDeviceInfo.GenerateUUID(); NpDebugLog.Log("create uuid " + this.uuid); } else { this.uuid = aes.DecryptString(baseUUIDData); NpDebugLog.Log("load uuid " + this.uuid); } if (!this.isInitialized) { yield return(_behaviour.StartCoroutine(this.OauthInitialize(this.uuid, _behaviour))); } if (isNew && this.isInitialized) { PlayerPrefs.SetString("uuid", aes.EncryptString(this.uuid)); PlayerPrefs.Save(); } if (this.isInitializedError) { if (faildAction != null) { faildAction(this.mErrData); } } else if (this.isInitialized) { if (successAction != null) { successAction(); } } else if (faildAction != null) { this.mErrData.FailedCode = NpOatuhFailedCodeE.OtherException; this.mErrData.NativeErrLog = "No isInitialized"; faildAction(this.mErrData); } yield break; }
public void Init(MonoBehaviour behaviour, Action successAction, Action <NpOAuthErrData> faildAction, NpAes aes) { if (this.initURL.Equals(string.Empty) || this.counsumerKey.Equals(string.Empty) || this.counsumerSecret.Equals(string.Empty)) { if (faildAction != null) { this.mErrData.FailedCode = NpOatuhFailedCodeE.InitFaield; this.mErrData.NativeErrLog = "Not OAuthData"; faildAction(this.mErrData); } return; } behaviour.StartCoroutine(this.LoadOAuth(behaviour, successAction, faildAction, aes)); }