public IEnumerator Setup()
        {
            this.user = AccelBytePlugin.GetUser();

            if (this.user.Session.IsValid())
            {
                Result logoutResult = null;

                this.user.Logout(r => logoutResult = r);

                while (logoutResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }
            }

            Result loginWithDevice = null;

            this.user.LoginWithDeviceId(result => { loginWithDevice = result; });

            while (loginWithDevice == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            Debug.Log(this.user.Session.UserId);
            Assert.That(!loginWithDevice.IsError);
        }
    private void OutputAuthCode(Sony.NP.Auth.AuthCodeResponse response)
    {
        if (response == null)
        {
            return;
        }

        PrintLog("Auth Code Response");

        if (response.Locked == false)
        {
            PrintLog("AuthCode : " + response.AuthCode);
            PrintLog("IssuerId : " + response.IssuerId);
            var user = AccelBytePlugin.GetUser();
            PrintLog("\nLogin to AB");
            user.LoginWithOtherPlatform(AccelByte.Models.PlatformType.PS4, response.AuthCode, result =>
            {
                if (!result.IsError)
                {
                    PrintLog("\nLogin Success!");
                    user.GetData(resultData =>
                    {
                        if (!resultData.IsError)
                        {
                            PrintLog("\nUserId: " + resultData.Value.userId);
                            PrintLog("\nDisplayName: " + resultData.Value.displayName);
                        }
                    });
                }
            });
        }
    }
Пример #3
0
        public IEnumerator Setup()
        {
            var user = AccelBytePlugin.GetUser();

            Result loginWithDevice = null;

            user.LoginWithDeviceId(result => { loginWithDevice = result; });

            while (loginWithDevice == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            Result <UserData> getDataResult = null;

            user.GetData(r => getDataResult = r);

            while (getDataResult == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            TestHelper.LogResult(getDataResult);
            TestHelper.Assert.That(getDataResult.IsError, Is.False);
            TestHelper.Assert.That(!loginWithDevice.IsError);
        }
Пример #4
0
    /// <summary>
    /// When logout button pressed, redirect to LoginPage scene.
    /// </summary>
    void OnLogoutClicked()
    {
        User user = AccelBytePlugin.GetUser();

        user.Logout();
        SceneManager.LoadScene(SceneNames.LoginPage.ToString());
    }
Пример #5
0
 /// <summary>
 /// Use this for initialization
 /// </summary>
 void Start()
 {
     AssignSceneComponents();
     user            = AccelBytePlugin.GetUser();
     entitlements    = AccelBytePlugin.GetEntitlements();
     entitlementList = new List <PagedEntitlements>();
     pageNow         = 0;
     pageSize        = 18;
     entitlements.GetUserEntitlements(pageNow, pageSize, OnGetUserEntitlements);
 }
    void SignIn()
    {
        try
        {
            Sony.NP.Auth.GetAuthCodeRequest request = new Sony.NP.Auth.GetAuthCodeRequest();

            // test values from SDK nptoolkit sample ... replace with your own project values
            Sony.NP.Auth.NpClientId clientId = new Sony.NP.Auth.NpClientId();
            clientId.Id = "";

            request.ClientId = clientId;
            request.Scope    = "psn:s2s";
            request.UserId   = GetLocalProfiles();
            PrintLog("\nGet UserId Success! UserId: " + request.UserId);

            Sony.NP.Auth.AuthCodeResponse response = new Sony.NP.Auth.AuthCodeResponse();
            int requestId = Sony.NP.Auth.GetAuthCode(request, response);
            while (response.Locked)
            {
                new WaitForSeconds(1);
            }
            PrintLog("\n Return Code: " + response.ReturnCode);
            PrintLog("\nIssuerId: " + response.IssuerId);
            if (!response.IsErrorCode)
            {
                PrintLog("\nAuthCode: " + response.AuthCode);
                var user = AccelBytePlugin.GetUser();
                PrintLog("\nLogin to AB");
                user.LoginWithOtherPlatform(AccelByte.Models.PlatformType.PS4, response.AuthCode, result =>
                {
                    if (!result.IsError)
                    {
                        PrintLog("\nLogin Success!");
                        user.GetData(resultData =>
                        {
                            if (!resultData.IsError)
                            {
                                PrintLog("\nUserId: " + resultData.Value.userId);
                                PrintLog("\nDisplayName: " + resultData.Value.displayName);
                            }
                        });
                    }
                });
            }
        }
        catch (Sony.NP.NpToolkitException e)
        {
            PrintLog("\nException : " + e.ExtendedMessage);
        }
    }
    void SignIn()
    {
        GgpPlayerId playerId = StadiaNativeApis.GgpGetPrimaryPlayerId();

        float startTime = Time.realtimeSinceStartup;

        while (playerId.Value == (int)GgpIdConstants.kGgpInvalidId && Time.realtimeSinceStartup - startTime < 10f)
        {
            new WaitForSeconds(0.5f);
            playerId = StadiaNativeApis.GgpGetPrimaryPlayerId();
        }
        if (playerId.Value == (int)GgpIdConstants.kGgpInvalidId)
        {
            PrintLog("\n[STADIA] Can't retrieve playerId!");
        }
        PrintLog("\n[STADIA] PlayerId: " + playerId.Value);

        GgpStatus    reqStatus;
        GgpPlayerJwt playerJwt = StadiaNativeApis.GgpGetJwtForPlayer(playerId, 1000, new GgpJwtFields((ulong)GgpJwtFieldValues.kGgpJwtField_None)).GetResultBlocking <GgpPlayerJwt>(out reqStatus);

        PrintLog("\nPlayerJwt: " + playerJwt.jwt);

        var user = AccelBytePlugin.GetUser();

        PrintLog("\nLogin to AB");
        user.LoginWithOtherPlatform(AccelByte.Models.PlatformType.Stadia, playerJwt.jwt, loginResult =>
        {
            if (!loginResult.IsError)
            {
                PrintLog("\nLogin Success!");
                user.GetData(resultData =>
                {
                    if (!resultData.IsError)
                    {
                        PrintLog("\nUserId: " + resultData.Value.userId);
                        PrintLog("\nDisplayName: " + resultData.Value.displayName);
                    }
                });
            }
            else
            {
                PrintLog("\nCannot logged in.");
                PrintLog("\nError: " + loginResult.Error.Code + " | Message: " + loginResult.Error.Message);
            }
        });
    }
            public IEnumerator LoginTestUser()
            {
                var    user            = AccelBytePlugin.GetUser();
                Result userLoginResult = null;

                user.LoginWithDeviceId(result => { userLoginResult = result; });

                while (userLoginResult == null)
                {
                    yield return(new WaitForSeconds(0.1f));
                }

                TestHelper.Assert.IsTrue(!userLoginResult.IsError, "User cannot login.");

                TestVariables.userId = user.Session.UserId;

                TestHelper         testHelper     = new TestHelper();
                Result <TokenData> getAccessToken = null;

                testHelper.GetAccessToken(result => { getAccessToken = result; });

                while (getAccessToken == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getAccessToken.IsError, "Cannot get access token.");

                TestVariables.accessToken = getAccessToken.Value.access_token;

                DedicatedServer server      = AccelByteServerPlugin.GetDedicatedServer();
                Result          loginResult = null;

                server.LoginWithClientCredentials(result => loginResult = result);

                while (loginResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!loginResult.IsError, "Server cannot login.");
            }
            public IEnumerator GetDescendantCategory_CategoryValid_LanguageInvalid_Success()
            {
                var    user        = AccelBytePlugin.GetUser();
                Result loginResult = null;

                user.LoginWithDeviceId(result => loginResult = result);

                while (loginResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                Categories categories = AccelBytePlugin.GetCategories();
                Result <CategoryInfo[]> getDescendantCategoryResult = null;
                bool containDogeCoin = false;

                categories.GetDescendantCategories(
                    TestVariables.expectedRootCategoryPath,
                    "unknown",
                    result => { getDescendantCategoryResult = result; });

                while (getDescendantCategoryResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                foreach (CategoryInfo child in getDescendantCategoryResult.Value)
                {
                    if (child.categoryPath.Contains(TestVariables.expectedGrandChildCategoryPath))
                    {
                        containDogeCoin = true;
                    }
                }

                TestHelper.Assert.IsTrue(
                    !getDescendantCategoryResult.IsError,
                    "Get descendant category with invalid language failed.");
                TestHelper.Assert.IsTrue(containDogeCoin, "Get descendant category with invalid language failed.");
            }
    void SignIn()
    {
        try
        {
            //TODO: URL needs to be changed
            string url    = "";
            var    result = mCurrentUser.GetTokenAndSignatureAsync("POST", url, "");
            PrintLog("\n After GetTokenAndSignatureAsync...." + result);

            while (result.Status != Windows.Foundation.AsyncStatus.Completed)
            {
                PrintLog("\n Waiting...." + result.Status);
                System.Threading.Thread.Sleep(1000);
            }

            PrintLog("\nReturn Code: " + result.ErrorCode);
            PrintLog("\nAuthCode: " + result.GetResults().Token);
            var user = AccelBytePlugin.GetUser();
            PrintLog("\nLogin to AB");
            user.LoginWithOtherPlatform(AccelByte.Models.PlatformType.Live, result.GetResults().Token, loginResult =>
            {
                if (!loginResult.IsError)
                {
                    PrintLog("\nLogin Success!");
                    user.GetData(resultData =>
                    {
                        if (!resultData.IsError)
                        {
                            PrintLog("\nUserId: " + resultData.Value.userId);
                            PrintLog("\nDisplayName: " + resultData.Value.displayName);
                        }
                    });
                }
            });
        }
        catch (Exception ex)
        {
            PrintLog("\n Exception...." + ex);
            return;
        }
    }
 /// <summary>
 /// Use this for initialization
 /// </summary>
 void Start()
 {
     user = AccelBytePlugin.GetUser();
     AssignSceneComponents();
     user.GetData(OnGetUserData);
 }
Пример #12
0
        public IEnumerator TestSendEvent_WithStringData_ReturnsError()
        {
            var    userAccount      = AccelBytePlugin.GetUser();
            Result emailLoginResult = null;

            Result <RegisterUserResponse> registerResult = null;
            var user = AccelBytePlugin.GetUser();

            user.Register(
                "*****@*****.**",
                "Password123",
                "testeraccelbyte",
                "US",
                DateTime.Now.AddYears(-22),
                result => registerResult = result);

            while (registerResult == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            userAccount.LoginWithUsername(
                "*****@*****.**",
                "Password123",
                result => { emailLoginResult = result; });

            while (emailLoginResult == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            TestHelper.Assert.That(!emailLoginResult.IsError);

            var    telemetry       = AccelBytePlugin.GetTelemetry();
            Result telemetryResult = null;

            telemetry.SendEvent(new TelemetryEventTag(), "string data", result => { telemetryResult = result; });

            while (telemetryResult == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }


            Result deleteResult = null;
            var    helper       = new TestHelper();

            helper.DeleteUser(userAccount, result => deleteResult = result);

            while (deleteResult == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            Result logoutResult = null;

            userAccount.Logout(r => logoutResult = r);

            while (logoutResult == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            TestHelper.Assert.That(telemetryResult.IsError);
            TestHelper.Assert.That(deleteResult.IsError, Is.False);
            TestHelper.Assert.That(logoutResult.IsError, Is.False);
        }
Пример #13
0
        public IEnumerator Setup()
        {
            var user = AccelBytePlugin.GetUser();

            this.server = AccelByteServerPlugin.GetDedicatedServer();

            Result loginResult = null;

            this.server.LoginWithClientCredentials(result => loginResult = result);

            while (loginResult == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            Result loginWithDevice = null;

            user.LoginWithDeviceId(result => { loginWithDevice = result; });

            while (loginWithDevice == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            this.userId1 = user.Session.UserId;

            Result logoutResult = null;

            user.Logout(result => logoutResult = result);

            while (logoutResult == null)
            {
                yield return(new WaitForSeconds(0.1f));
            }

            var steamTicketBuilder = new StringBuilder();

            if (SteamManager.Initialized)
            {
                var  ticket = new byte[1024];
                uint actualTicketLength;
                SteamUser.GetAuthSessionTicket(ticket, ticket.Length, out actualTicketLength);
                Array.Resize(ref ticket, (int)actualTicketLength);

                foreach (byte b in ticket)
                {
                    steamTicketBuilder.AppendFormat("{0:x2}", b);
                }
            }

            Result steamLoginResult = null;

            user.LoginWithOtherPlatform(
                PlatformType.Steam,
                steamTicketBuilder.ToString(),
                result => steamLoginResult = result);

            while (steamLoginResult == null)
            {
                yield return(new WaitForSeconds(0.1f));
            }

            this.userId2 = user.Session.UserId;

            this.statistic = AccelByteServerPlugin.GetStatistic();

            //Get AccessToken
            Result <TokenData> GetAccessToken = null;

            this.helper.GetAccessToken(result => { GetAccessToken = result; });

            while (GetAccessToken == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            this.helperAccessToken = GetAccessToken.Value.access_token;

            for (int i = 0; i < this.statCodes.Length - 1; i++)
            {
                Debug.Log("Start to create stat! " + this.statCodes[i]);
                Result <StatConfig>        createStatResult = null;
                TestHelper.StatCreateModel createStat       = new TestHelper.StatCreateModel
                {
                    defaultValue  = 0,
                    description   = "Stat for SDK Test",
                    incrementOnly = true,
                    maximum       = 999999,
                    minimum       = 0,
                    name          = this.statCodes[i],
                    setAsGlobal   = false,
                    setBy         = StatisticSetBy.SERVER,
                    statCode      = this.statCodes[i],
                    tags          = new[] { this.tags[i] }
                };

                this.helper.CreateStatConfig(
                    this.helperAccessToken,
                    createStat,
                    result => { createStatResult = result; });

                while (createStatResult == null)
                {
                    yield return(new WaitForSeconds(0.1f));
                }
            }

            Debug.Log("Start to create stat! " + this.statCodes[5]);
            Result <StatConfig> createStat6Result = null;

            TestHelper.StatCreateModel createStat6 = new TestHelper.StatCreateModel
            {
                defaultValue  = 0,
                description   = "Stat for SDK Test",
                incrementOnly = false,
                maximum       = 999999,
                minimum       = 0,
                name          = this.statCodes[5],
                setAsGlobal   = false,
                setBy         = StatisticSetBy.SERVER,
                statCode      = this.statCodes[5],
                tags          = new[] { this.tags[5] }
            };

            this.helper.CreateStatConfig(
                this.helperAccessToken,
                createStat6,
                result => { createStat6Result = result; });

            while (createStat6Result == null)
            {
                yield return(new WaitForSeconds(0.1f));
            }

            foreach (string statCode in this.statCodes)
            {
                Result deleteResult = null;

                this.helper.DeleteStatItem(
                    this.helperAccessToken,
                    this.userId1,
                    statCode,
                    result => deleteResult = result);

                while (deleteResult == null)
                {
                    yield return(new WaitForSeconds(0.1f));
                }

                deleteResult = null;

                this.helper.DeleteStatItem(
                    this.helperAccessToken,
                    this.userId2,
                    statCode,
                    result => deleteResult = result);

                while (deleteResult == null)
                {
                    yield return(new WaitForSeconds(0.1f));
                }
            }
        }
Пример #14
0
 /// <summary>
 /// Use this for initialization
 /// </summary>
 void Start()
 {
     user = AccelBytePlugin.GetUser();
     AssignSceneComponent();
 }
            public IEnumerator Z_DeleteDependencies()
            {
                TestHelper testHelper = new TestHelper();
                var        user       = AccelBytePlugin.GetUser();

                Result deleteResult = null;

                testHelper.DeleteUser(user, result => { deleteResult = result; });

                //			testHelper.DeleteUser(AccelBytePlugin.Config.Namespace, PlatformType.Device, "", result => { deleteResult = result; });
                while (deleteResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.That(!deleteResult.IsError);

                Result <TestHelper.StoreInfoModel> storeDeleteResult = null;

                testHelper.DeleteStore(
                    TestVariables.accessToken,
                    TestVariables.createdTemporaryStoreInfoId,
                    result => { storeDeleteResult = result; });

                while (storeDeleteResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.That(!storeDeleteResult.IsError);

                if (TestVariables.bPublishedStoreIsExist)
                {
                    Result <TestHelper.StoreInfoModel> cloneResult = null;
                    testHelper.CloneStore(
                        TestVariables.accessToken,
                        TestVariables.createdArchiveStoreInfoId,
                        TestVariables.publishedStoreId,
                        result => { cloneResult = result; });

                    while (cloneResult == null)
                    {
                        Thread.Sleep(100);

                        yield return(null);
                    }

                    TestHelper.Assert.That(!cloneResult.IsError);

                    storeDeleteResult = null;
                    testHelper.DeleteStore(
                        TestVariables.accessToken,
                        TestVariables.createdArchiveStoreInfoId,
                        result => { storeDeleteResult = result; });

                    while (storeDeleteResult == null)
                    {
                        Thread.Sleep(100);

                        yield return(null);
                    }

                    TestHelper.Assert.That(!storeDeleteResult.IsError);
                }
                else
                {
                    storeDeleteResult = null;
                    testHelper.DeletePublishedStore(TestVariables.accessToken, result => { storeDeleteResult = result; });

                    while (storeDeleteResult == null)
                    {
                        Thread.Sleep(100);

                        yield return(null);
                    }

                    TestHelper.Assert.That(!storeDeleteResult.IsError);
                }

                Result <TestHelper.CurrencyInfoModel> deleteCurrencyResult = null;

                testHelper.DeleteCurrency(
                    TestVariables.accessToken,
                    TestVariables.currencyCode,
                    result => { deleteCurrencyResult = result; });

                while (deleteCurrencyResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.That(!deleteCurrencyResult.IsError);
            }
        public IEnumerator Setup()
        {
            this.user = AccelBytePlugin.GetUser();

            Result loginWithDevice = null;

            this.user.LoginWithDeviceId(result => { loginWithDevice = result; });

            while (loginWithDevice == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            Debug.Log(this.user.Session.UserId);
            this.statistic = AccelBytePlugin.GetStatistic();

            //Get AccessToken
            Result <TokenData> GetAccessToken = null;

            this.helper.GetAccessToken(result => { GetAccessToken = result; });

            while (GetAccessToken == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            this.helperAccessToken = GetAccessToken.Value.access_token;

            for (int i = 0; i < this.statCodes.Length - 1; i++)
            {
                Debug.Log("Start to create stat! " + this.statCodes[i]);
                Result <StatConfig>        createStatResult = null;
                TestHelper.StatCreateModel createStat       = new TestHelper.StatCreateModel
                {
                    defaultValue  = 0,
                    description   = "Stat for SDK Test",
                    incrementOnly = true,
                    maximum       = 999999,
                    minimum       = 0,
                    name          = this.statCodes[i],
                    setAsGlobal   = false,
                    setBy         = StatisticSetBy.CLIENT,
                    statCode      = this.statCodes[i],
                    tags          = new[] { this.tags[i] }
                };

                this.helper.CreateStatConfig(
                    this.helperAccessToken,
                    createStat,
                    result => { createStatResult = result; });

                while (createStatResult == null)
                {
                    yield return(new WaitForSeconds(0.1f));
                }
            }

            Debug.Log("Start to create stat! " + this.statCodes[5]);
            Result <StatConfig> createStat6Result = null;

            TestHelper.StatCreateModel createStat6 = new TestHelper.StatCreateModel
            {
                defaultValue  = 0,
                description   = "Stat for SDK Test",
                incrementOnly = false,
                maximum       = 999999,
                minimum       = 0,
                name          = this.statCodes[5],
                setAsGlobal   = false,
                setBy         = StatisticSetBy.CLIENT,
                statCode      = this.statCodes[5],
                tags          = new[] { this.tags[5] }
            };

            this.helper.CreateStatConfig(
                this.helperAccessToken,
                createStat6,
                result => { createStat6Result = result; });

            while (createStat6Result == null)
            {
                yield return(new WaitForSeconds(0.1f));
            }
        }