Sign In Register

How can we help you today?

Start a new topic

Unity Error in LogEventRequest response causes infinite loop?

Just wondering if this intended behavior or not. Have a simple database query:

new GameSparks.Api.Requests.LogEventRequest()
            .SetEventKey("LOAD_PUZZLES")
            .Send((response) =>
            {
                if (!response.HasErrors)
                {
                    Debug.Log("Received Player Data From GameSparks...");
                    GSData data = response.ScriptData.GetGSData("PUZZLE_DATA");
                    print("User: " + data.GetString("username"));
                    print("Puzzles: " + data.GetStringList("puzzles"));
                }
                else
                {
                    Debug.Log("Error Loading Player Data...");
                }
            });

My cloud code just looks for the document that contains a matching username field of the user sending the request. I've noticed that if the entry I'm looking for doesn't exist, the code will hit an error when it tries to call GetString on data, and then seems to repeatedly send the EventRequest and fail over and over. If a match is found though it works perfectly. Is there a reason this happens?

Thanks




1 person has this question
1 Comment

  

if (!response.HasErrors)
                {
                       Debug.Log("Received Player Data From GameSparks...");
                       GSData data = response.ScriptData.GetGSData("PUZZLE_DATA");
                       string user =  data.ContainsKey("username")? data.GetString("username") : "";
                       string puzzles =  data.ContainsKey("puzzles") ? data.GetString("puzzles") : "{}";
                       print("User: " + user);
                       print("Puzzles: " + puzzles);
                }
                else
                {
                    Debug.Log("Error Loading Player Data...");
                }
}

  


1 person likes this
Login to post a comment