예제 #1
0
        public static void Initialize(string gameKey, string gameSecret)
        {
#if WINDOWS_UWP || WINDOWS_WSA || WINDOWS_PHONE
            CoreApplication.Suspending += OnSuspending;
            CoreApplication.Resuming   += OnResuming;
#endif
            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("initialize", () =>
            {
                if (IsSdkReady(true, false))
                {
                    GALogger.W("SDK already initialized. Can only be called once.");
                    return;
                }
                if (!GAValidator.ValidateKeys(gameKey, gameSecret))
                {
                    GALogger.W("SDK failed initialize. Game key or secret key is invalid. Can only contain characters A-z 0-9, gameKey is 32 length, gameSecret is 40 length. Failed keys - gameKey: " + gameKey + ", secretKey: " + gameSecret);
                    return;
                }

                GAState.SetKeys(gameKey, gameSecret);

                if (!GAStore.EnsureDatabase(false))
                {
                    GALogger.W("Could not ensure/validate local event database: " + GADevice.WritablePath);
                }

                GAState.InternalInitialize();
            });
        }
예제 #2
0
        public static void Initialize(string gamekey, string gamesecret)
        {
#if UNITY_EDITOR
            if (GAValidator.ValidateKeys(gamekey, gamesecret))
            {
                initialize(gamekey, gamesecret);
            }
#else
            initialize(gamekey, gamesecret);
#endif
        }
예제 #3
0
        public void TestValidateKeysWithGameKey()
        {
            string validGameKey   = "123456789012345678901234567890ab";
            string validSecretKey = "123456789012345678901234567890123456789a";

            string tooLongKey = "123456789012345678901234567890123456789abcdefg";

            Assert.False(GAValidator.ValidateKeys(validGameKey, null));
            Assert.False(GAValidator.ValidateKeys(validGameKey, ""));
            Assert.False(GAValidator.ValidateKeys(validGameKey, "123"));
            Assert.False(GAValidator.ValidateKeys(validGameKey, tooLongKey));

            Assert.False(GAValidator.ValidateKeys(null, validSecretKey));
            Assert.False(GAValidator.ValidateKeys("", validSecretKey));
            Assert.False(GAValidator.ValidateKeys("123", validSecretKey));
            Assert.False(GAValidator.ValidateKeys(tooLongKey, validSecretKey));

            Assert.True(GAValidator.ValidateKeys(validGameKey, validSecretKey));
        }