コード例 #1
0
    private void SpilGameDataErrorHandler(SpilErrorMessage errorMessage)
    {
        txtErrorMessage.text = errorMessage.name + ": " + errorMessage.message;
        pnlErrorMessage.SetActive(true);

        updateUI();
        updateUIShop();
    }
コード例 #2
0
        public static void ProcessUserLoginError(JSONObject socialLoginJSON)
        {
            if (socialLoginJSON.HasField("authError"))
            {
                long authError = socialLoginJSON.GetField("authError").i;

                SpilErrorMessage error = new SpilErrorMessage();

                switch (authError)
                {
                case 1:
                    error.id      = 32;
                    error.name    = "InvalidSpilTokenError";
                    error.message = "Spil Token is invalid! Please login again!";
                    break;

                case 3:
                    error.id      = 34;
                    error.name    = "InvalidSocialTokenError";
                    error.message = "The provided social token could not be verified with the backend";
                    break;

                case 4:
                    error.id      = 35;
                    error.name    = "UserAlreadyLinkedError";
                    error.message = "User already has a social provider account";
                    break;

                case 5:
                    error.id      = 36;
                    error.name    = "SocialIdAlreadyLinkedError";
                    error.message = "The social id is already linked to another user!";
                    break;

                default:
                    error.id      = 37;
                    error.name    = "SocialLoginServerError";
                    error.message = "Error communicating with the server!";
                    break;
                }

                SpilUnityImplementationBase.fireLoginFailed(JsonUtility.ToJson(error));
            }
            else
            {
                SpilErrorMessage error = new SpilErrorMessage();
                error.id      = 37;
                error.name    = "SocialLoginServerError";
                error.message = "Error communicating with the server!";

                SpilUnityImplementationBase.fireLoginFailed(JsonUtility.ToJson(error));
            }
        }
コード例 #3
0
        public static void ProcessUserLogin(JSONObject socialLoginJSON)
        {
            if (socialLoginJSON == null)
            {
                SpilErrorMessage error = new SpilErrorMessage();
                error.id      = 37;
                error.name    = "SocialLoginServerError";
                error.message = "Error communicating with the server!";
                SpilUnityImplementationBase.fireLoginFailed(JsonUtility.ToJson(error));

                return;
            }

            string uid            = socialLoginJSON.GetField("uid").str;
            string spilToken      = socialLoginJSON.GetField("spilToken").str;
            string socialProvider = socialLoginJSON.GetField("socialProvider").str;
            string socialId       = socialLoginJSON.GetField("socialId").str;

            if (uid != null && spilToken != null && socialProvider != null && socialId != null)
            {
                bool resetData = false;

                if (!Spil.SpilUserIdEditor.Equals(uid))
                {
                    resetData             = true;
                    Spil.SpilUserIdEditor = uid;
                }

                SpilUnityEditorImplementation.spilToken = spilToken;

                Spil.Instance.SetUserId(socialProvider, socialId);

                SpilUnityEditorImplementation.unauthorized = false;

                JSONObject loginMessage = new JSONObject();
                loginMessage.AddField("resetData", resetData);
                loginMessage.AddField("socialProvider", socialProvider);
                loginMessage.AddField("socialId", socialId);
                loginMessage.AddField("isGuest", false);

                SpilUnityImplementationBase.fireLoginSuccessful(loginMessage.Print());
            }
            else
            {
                SpilErrorMessage error = new SpilErrorMessage();
                error.id      = 37;
                error.name    = "SocialLoginServerError";
                error.message = "Error communicating with the server!";
                SpilUnityImplementationBase.fireLoginFailed(JsonUtility.ToJson(error));
            }
        }
コード例 #4
0
        public static void ProcessUnauthorizedResponse(string errorJSONString)
        {
            if (SpilUnityEditorImplementation.unauthorized)
            {
                return;
            }

            SpilUnityEditorImplementation.unauthorized = true;

            JSONObject errorJSON = new JSONObject(errorJSONString);

            if (errorJSON.HasField("authError"))
            {
                long authError = errorJSON.GetField("authError").i;

                SpilErrorMessage error = new SpilErrorMessage();

                switch (authError)
                {
                case 1:
                    error.id      = 32;
                    error.name    = "InvalidSpilTokenError";
                    error.message = "Spil Token is invalid! Please login again!";
                    break;

                case 2:
                    error.id      = 33;
                    error.name    = "RequriesLoginError";
                    error.message = "Event requires user login!";
                    break;

                default:
                    error.id      = 37;
                    error.name    = "SocialLoginServerError";
                    error.message = "Error communicating with the server!";
                    break;
                }

                SpilUnityImplementationBase.fireAuthenticationError(JsonUtility.ToJson(error));
            }
            else
            {
                SpilErrorMessage error = new SpilErrorMessage();
                error.id      = 37;
                error.name    = "SocialLoginServerError";
                error.message = "Error communicating with the server!";

                SpilUnityImplementationBase.fireAuthenticationError(JsonUtility.ToJson(error));
            }
        }
コード例 #5
0
        public static void SetPublicGameState(String gameState)
        {
            if (Response.externalId != null && Response.provider != null)
            {
                UserDataManager.UpdateUserDataVersions();
                UserDataManager.UpdateUserDataMeta();

                SpilEvent spilEvent = Spil.MonoInstance.gameObject.AddComponent <SpilEvent>();
                spilEvent.eventName = "updateGameState";

                if (gameState.Contains("\""))
                {
                    gameState = gameState.Replace("\"", "\\\"").Replace("\\\\", "\\");
                }

                PublicGameStateData = gameState;

                JSONObject gameStateJSONArray = new JSONObject(JSONObject.Type.ARRAY);
                JSONObject gameStateJSON      = new JSONObject();

                gameStateJSON.AddField("data", gameState);
                gameStateJSON.AddField("access", "public");
                gameStateJSONArray.Add(gameStateJSON);

                spilEvent.customData.AddField("gameStates", gameStateJSONArray);
                spilEvent.customData.AddField("deviceVersions", UserDataManager.GenerateUserDataVersionsJSON(UserDataManager.userDataVersions));

                spilEvent.Send();
            }
            else
            {
                SpilErrorMessage error = new SpilErrorMessage();
                error.id      = 12;
                error.name    = "UserIdMissing";
                error.message =
                    "Error adding public game state data! A custom user id must be set in order to save public game state data";
                SpilUnityImplementationBase.fireUserDataError(JsonUtility.ToJson(error));
            }
        }
コード例 #6
0
        public static void SetPublicGameState(String gameState)
        {
            if (Response.externalId != null && Response.provider != null) {
                PublicGameStateData = gameState;

                SpilEvent spilEvent = Spil.MonoInstance.gameObject.AddComponent<SpilEvent> ();
                spilEvent.eventName = "updateGameState";

                gameState = gameState.Replace ("\"", "\\\"");

                spilEvent.customData.AddField ("data", gameState);
                spilEvent.customData.AddField ("access", "public");

                spilEvent.Send ();

            } else {
                SpilErrorMessage error = new SpilErrorMessage ();
                error.id = 12;
                error.name = "UserIdMissing";
                error.message = "Error adding public game state data! A custom user id must be set in order to save public game state data";
                SpilUnityImplementationBase.fireGameStateError (JsonUtility.ToJson (error));
            }
        }
コード例 #7
0
 public void DailyBonusErrorHandler(SpilErrorMessage message)
 {
     txtWebStatus2.text += "\nDailybonus error: " + message;
 }
コード例 #8
0
 public void SplashScreenErrorHandler(SpilErrorMessage message)
 {
     txtWebStatus2.text += "\nSplashscreen error: " + message;
 }