예제 #1
0
        public void TestValidateSdkErrorEvent()
        {
            // Store result
            bool isValid;

            // Valid
            isValid = GAValidator.ValidateSdkErrorEvent("c6cfc80ff69d1e7316bf1e0c8194eda6", "e0ae4809f70e2fa96916c7060f417ae53895f18d", EGASdkErrorType.Rejected);
            Assert.True(isValid, "Sdk error event should validate");
        }
예제 #2
0
        public void SendSdkErrorEvent(EGASdkErrorType type)
        {
            if (!GAState.IsEventSubmissionEnabled)
            {
                return;
            }

            string gameKey   = GAState.GameKey;
            string secretKey = GAState.GameSecret;

            // Validate
            if (!GAValidator.ValidateSdkErrorEvent(gameKey, secretKey, type))
            {
                return;
            }

            // Generate URL
            string url = baseUrl + "/" + gameKey + "/" + eventsUrlPath;

            GALogger.D("Sending 'events' URL: " + url);

            string payloadJSONString = "";

            JSONObject json = GAState.GetSdkErrorEventAnnotations();

            string typeString = SdkErrorTypeToString(type);

            json.Add("type", typeString);

            List <JSONNode> eventArray = new List <JSONNode>();

            eventArray.Add(json);
            payloadJSONString = GAUtilities.ArrayOfObjectsToJsonString(eventArray);

            if (string.IsNullOrEmpty(payloadJSONString))
            {
                GALogger.W("sendSdkErrorEvent: JSON encoding failed.");
                return;
            }

            GALogger.D("sendSdkErrorEvent json: " + payloadJSONString);
            byte[]       payloadData  = Encoding.UTF8.GetBytes(payloadJSONString);
            SdkErrorTask sdkErrorTask = new SdkErrorTask(type, payloadData, secretKey);

            sdkErrorTask.Execute(url);
        }