Exemplo n.º 1
0
        public static void FireNotSupportedAPI(object classObj, GamebaseCallback.VoidDelegate callback, [System.Runtime.CompilerServices.CallerMemberName] string methodName = "")
        {
            if (callback == null)
            {
                return;
            }

            GamebaseLog.Warn(string.Format("{0}", CreateNotSupportedMessage()), classObj, methodName);
            callback();
        }
        public List <GamebaseResponse.Purchase.PurchasableItem> GetPurchasableReceiptList()
        {
            if (adapter == null)
            {
                GamebaseLog.Warn(GamebaseStrings.PURCHASE_ADAPTER_NOT_FOUND, this, "GetPurchasableReceiptList");
                return(null);
            }

            return(adapter.GetPurchasableReceiptList());
        }
Exemplo n.º 3
0
        public static void FireNotSupportedAPI(object classObj, string methodName, GamebaseCallback.VoidDelegate callback)
        {
            if (callback == null)
            {
                return;
            }

            GamebaseLog.Warn(string.Format("{0}", CreateNotSupportedMessage()), classObj, methodName);
            callback();
        }
Exemplo n.º 4
0
        public bool IsSandbox()
        {
            if (GamebaseUnitySDK.IsInitialized == false)
            {
                GamebaseLog.Warn(GamebaseStrings.NOT_INITIALIZED, this);
                return(false);
            }

            var vo = DataContainer.GetData <LaunchingResponse.LaunchingInfo>(VOKey.Launching.LAUNCHING_INFO);

            return(vo.launching.app.typeCode.Equals("SANDBOX", System.StringComparison.Ordinal));
        }
Exemplo n.º 5
0
        public GamebaseResponse.Launching.LaunchingInfo GetLaunchingInformations()
        {
            if (GamebaseUnitySDK.IsInitialized == false)
            {
                GamebaseLog.Warn(GamebaseStrings.NOT_INITIALIZED, this);
                return(null);
            }

            var vo = DataContainer.GetData <LaunchingResponse.LaunchingInfo>(VOKey.Launching.LAUNCHING_INFO);

            return(JsonMapper.ToObject <GamebaseResponse.Launching.LaunchingInfo>(JsonMapper.ToJson(vo)));
        }
Exemplo n.º 6
0
        public int GetLaunchingStatus()
        {
            if (GamebaseUnitySDK.IsInitialized == false)
            {
                GamebaseLog.Warn(GamebaseStrings.NOT_INITIALIZED, this);
                return(0);
            }

            var vo = DataContainer.GetData <LaunchingResponse.LaunchingInfo>(VOKey.Launching.LAUNCHING_INFO);

            return(vo.launching.status.code);
        }
Exemplo n.º 7
0
        public static void FireNotSupportedAPI <T>(object classObj, GamebaseCallback.GamebaseDelegate <T> callback, [System.Runtime.CompilerServices.CallerMemberName] string methodName = "")
        {
            if (callback == null)
            {
                return;
            }

            GamebaseLog.Warn(string.Format("{0}", CreateNotSupportedMessage()), classObj, methodName);
            string message = string.Format("{0} - {1}.", methodName, CreateNotSupportedMessage());

            callback(default(T), CreateNotSupportedError(classObj.GetType().Name, message));
        }
Exemplo n.º 8
0
        public static void FireNotSupportedAPI(object classObj, string methodName, GamebaseCallback.ErrorDelegate callback)
        {
            if (callback == null)
            {
                return;
            }

            GamebaseLog.Warn(string.Format("{0}", CreateNotSupportedMessage()), classObj, methodName);
            string message = string.Format("{0} - {1}.", methodName, CreateNotSupportedMessage());

            callback(CreateNotSupportedError(classObj.GetType().Name, message));
        }
        public void SetUserMeta(RequestType type)
        {
            if (string.IsNullOrEmpty(Gamebase.GetUserID()) == true)
            {
                GamebaseLog.Warn("Not LoggedIn", this, "SetUserMeta");
                return;
            }

            GamebaseLog.Debug(
                string.Format("SetUserMeta Type : {0}", type.ToString()),
                this,
                "SetUserMeta");

            AnalyticsRequest.UserMetaVO vo = new AnalyticsRequest.UserMetaVO();
            vo.payload.appId    = GamebaseUnitySDK.AppID;
            vo.parameter.userId = Gamebase.GetUserID();

            switch (type)
            {
            case RequestType.USER_DATA:
            {
                vo.payload.userMetaData = MakeUserMetaData();
                break;
            }

            case RequestType.LEVEL_UP:
            {
                vo.payload.userMetaData = MakeLevelUpData();
                break;
            }
            }

            var requestVO = new WebSocketRequest.RequestVO(PRODUCT_ID, Lighthouse.API.VERSION, GamebaseUnitySDK.AppID);

            requestVO.apiId      = ID.SET_USER_META;
            requestVO.payload    = JsonMapper.ToJson(vo.payload);
            requestVO.parameters = vo.parameter;

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                if (Gamebase.IsSuccess(error) == false)
                {
                    GamebaseLog.Warn(
                        string.Format(
                            "{0}\n{1}",
                            "Failed request.",
                            GamebaseJsonUtil.ToPrettyJsonString(error)),
                        this,
                        "SetUserMeta");
                }
            });
        }
        public override void CloseWebView()
        {
            bool hasAdapter = WebviewAdapterManager.Instance.CreateWebviewAdapter("standalonewebviewadapter");

            if (false == hasAdapter)
            {
                GamebaseLog.Warn(GamebaseStrings.WEBVIEW_ADAPTER_NOT_FOUND, this);

                return;
            }

            WebviewAdapterManager.Instance.CloseWebView();
        }
Exemplo n.º 11
0
        public void IssueShortTermTicket(int handle)
        {
            if (string.IsNullOrEmpty(Gamebase.GetUserID()) == true)
            {
                GamebaseLog.Warn("Not LoggedIn", this, "CompletePurchase");
                return;
            }

            GamebaseLog.Debug("Start", this, "IssueShortTermTicket");

            byte[] bytesForEncoding = Encoding.UTF8.GetBytes(ISSUE_SHORT_TERM_TICKET_PURPOSE);
            string encodedString    = Convert.ToBase64String(bytesForEncoding);

            var requestVO = AuthMessage.GetIssueShortTermTicketMessage(encodedString, ISSUE_SHORT_TERM_TICKET_EXPIRESIN);

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <string> >(handle);
                if (callback == null)
                {
                    return;
                }

                GamebaseCallbackHandler.UnregisterCallback(handle);

                if (error == null)
                {
                    var vo = JsonMapper.ToObject <AuthResponse.IssueShortTermTicketInfo>(response);
                    if (vo.header.isSuccessful == true)
                    {
                    }
                    else
                    {
                        error = GamebaseErrorUtil.CreateGamebaseErrorByServerErrorCode(requestVO.transactionId, requestVO.apiId, vo.header, Domain);
                    }

                    callback(vo.ticket, error);
                }
                else
                {
                    callback(null, error);
                }
            });
        }
        public void CompletePurchase(GamebaseResponse.Purchase.PurchasableReceipt purchasableReceipt)
        {
            if (string.IsNullOrEmpty(Gamebase.GetUserID()) == true)
            {
                GamebaseLog.Warn("Not LoggedIn", this, "CompletePurchase");
                return;
            }

            GamebaseLog.Debug("Start", this, "CompletePurchase");

            AnalyticsRequest.PurchaseVO vo = new AnalyticsRequest.PurchaseVO();
            vo.parameter.userId = Gamebase.GetUserID();

            vo.payload.appId             = GamebaseUnitySDK.AppID;
            vo.payload.paySeq            = purchasableReceipt.paymentSeq;
            vo.payload.clientVersion     = GamebaseUnitySDK.AppVersion;
            vo.payload.idPCode           = IdPCode;
            vo.payload.deviceModel       = GamebaseUnitySDK.DeviceModel;
            vo.payload.osCode            = GamebaseUnitySDK.Platform;
            vo.payload.usimCountryCode   = "ZZ";
            vo.payload.deviceCountryCode = GamebaseUnitySDK.CountryCode;
            vo.payload.userMetaData      = MakeUserMetaData();

            var requestVO = new WebSocketRequest.RequestVO(PRODUCT_ID, Lighthouse.API.VERSION, GamebaseUnitySDK.AppID);

            requestVO.apiId      = ID.COMPLETE_PURCHASE;
            requestVO.parameters = vo.parameter;
            requestVO.payload    = JsonMapper.ToJson(vo.payload);

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                if (Gamebase.IsSuccess(error) == false)
                {
                    GamebaseLog.Warn(
                        string.Format(
                            "{0}\n{1}",
                            "Failed request.",
                            GamebaseJsonUtil.ToPrettyJsonString(error)),
                        this,
                        "CompletePurchase");
                }
            });
        }
Exemplo n.º 13
0
        private IEnumerator LoadWebFile(string filePath)
        {
            UnityWebRequest www = UnityWebRequest.Get(filePath);

            www.timeout = CommunicatorConfiguration.timeout;

            yield return(UnityCompatibility.UnityWebRequest.Send(www));

            if (true == www.isDone)
            {
                if (200 == www.responseCode)
                {
                    if (true == UnityCompatibility.UnityWebRequest.IsError(www))
                    {
                        GamebaseLog.Warn(string.Format("error:{0}", www.error), this);
                    }
                    else
                    {
                        if (true == string.IsNullOrEmpty(www.downloadHandler.text))
                        {
                            GamebaseLog.Warn(GamebaseStrings.LOCALIZED_STRING_EMPTY, this);
                            yield break;
                        }

                        jsonString       = www.downloadHandler.text;
                        localizedStrings = JsonMapper.ToObject <Dictionary <string, LocalizedStringVO> >(jsonString);
                        GamebaseLog.Debug(GamebaseStrings.LOCALIZED_STRING_LOAD_SUCCEEDED, this);
                    }
                }
                else
                {
                    if (404 == www.responseCode)
                    {
                        GamebaseLog.Warn(string.Format("{0} responseCode:{1}.", GamebaseStrings.LOCALIZED_STRING_NOT_FOUND, www.responseCode), this);
                    }
                    else
                    {
                        GamebaseLog.Warn(string.Format("{0} responseCode:{1}.", GamebaseStrings.LOCALIZED_STRING_LOAD_FAILED, www.responseCode), this);
                    }
                }
            }
        }
Exemplo n.º 14
0
        private void LoadLocalFile(string filePath)
        {
            if (true == File.Exists(filePath))
            {
                jsonString = File.ReadAllText(filePath);

                if (true == string.IsNullOrEmpty(jsonString))
                {
                    GamebaseLog.Warn(GamebaseStrings.LOCALIZED_STRING_EMPTY, this);
                }
                else
                {
                    localizedStrings = JsonMapper.ToObject <Dictionary <string, LocalizedStringVO> >(jsonString);
                }
            }
            else
            {
                GamebaseLog.Warn(GamebaseStrings.LOCALIZED_STRING_NOT_FOUND, this);
            }
        }
Exemplo n.º 15
0
        public string GetString(string key)
        {
            if (null == localizedStrings)
            {
                return(string.Empty);
            }

            FieldInfo fieldInfo = typeof(LocalizedStringVO).GetField(key);

            if (null == fieldInfo)
            {
                GamebaseLog.Error(string.Format("`{0}` {1}", key, GamebaseStrings.LOCALIZED_STRING_KEY_NOT_SUPPORTED), this);
                return(string.Empty);
            }

            if (true == string.IsNullOrEmpty((string)fieldInfo.GetValue(GetLocalizedStringVO())))
            {
                if (true == HasKey(key))
                {
                    return(string.Empty);
                }
                else
                {
                    if (true == string.IsNullOrEmpty((string)fieldInfo.GetValue(GetDefaultLocalizedStringVO())))
                    {
                        GamebaseLog.Warn(string.Format("`{0}` {1}", key, GamebaseStrings.LOCALIZED_STRING_KEY_NOT_FOUND), this);
                        return(string.Empty);
                    }
                    else
                    {
                        return(fieldInfo.GetValue(GetDefaultLocalizedStringVO()).ToString());
                    }
                }
            }
            else
            {
                return(fieldInfo.GetValue(GetLocalizedStringVO()).ToString());
            }
        }
Exemplo n.º 16
0
        public void SetDisplayLanguageCode(string languageCode)
        {
            if (true == DisplayLanguage.Instance.HasLocalizedStringVO(languageCode))
            {
                GamebaseUnitySDK.DisplayLanguageCode = languageCode;
            }
            else
            {
                var launchingVO = DataContainer.GetData <LaunchingResponse.LaunchingInfo>(VOKey.Launching.LAUNCHING_INFO);
                var launchingDeviceLanguageCode = launchingVO.launching.app.language.deviceLanguage;

                if (true == DisplayLanguage.Instance.HasLocalizedStringVO(launchingDeviceLanguageCode))
                {
                    GamebaseUnitySDK.DisplayLanguageCode = launchingDeviceLanguageCode;
                    GamebaseLog.Warn(GamebaseStrings.DISPLAY_LANGUAGE_CODE_NOT_FOUND, this);
                }
                else
                {
                    GamebaseUnitySDK.DisplayLanguageCode = GamebaseDisplayLanguageCode.English;
                    GamebaseLog.Warn(GamebaseStrings.SET_DEFAULT_DISPLAY_LANGUAGE_CODE, this);
                }
            }
        }
 public void FireNotSupportedAPI(string domain, string methodName)
 {
     GamebaseLog.Warn(string.Format("{0} API is not supported by {1}.", methodName, domain), this);
 }
Exemplo n.º 18
0
 private void OnError(object sender, ErrorEventArgs e)
 {
     errorMessage = e.Message;
     GamebaseLog.Warn(GamebaseJsonUtil.ToPrettyJsonString(e), this);
 }
Exemplo n.º 19
0
 public static void FireNotSupportedAPI(object classObj, string methodName)
 {
     GamebaseLog.Warn(string.Format("{0}", CreateNotSupportedMessage()), classObj, methodName);
 }
Exemplo n.º 20
0
 public static void FireNotSupportedAPI(object classObj, [System.Runtime.CompilerServices.CallerMemberName] string methodName = "")
 {
     GamebaseLog.Warn(string.Format("{0}", CreateNotSupportedMessage()), classObj, methodName);
 }