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)); } } }
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)); } }