Пример #1
0
        void onEventOccurred(string eventName, string eventDataJson)
        {
            Dictionary <string, object> eventData = new Dictionary <string, object>();

            if (!String.IsNullOrEmpty(eventDataJson))
            {
                eventData = (Dictionary <string, object>)Json.Deserialize(eventDataJson);
            }
            externalHelpshiftEventsListener.HandleHelpshiftEvent(eventName, eventData);
        }
        private static void UnityHelpshiftDelegateCallbackImpl(string methodName, string parametersJson)
        {
            IHelpshiftEventsListener externalDelegate = GetInstance().externalDelegate;

            if (externalDelegate == null)
            {
                return;
            }

            if (methodName == HelpshiftEventConstants.HandleHelpshiftEvent)
            {
                Dictionary <string, object> eventJson = (Dictionary <string, object>)Json.Deserialize(parametersJson);
                string eventName = "";
                if (eventJson.ContainsKey("eventName"))
                {
                    eventName = (string)eventJson["eventName"];
                }

                object eventData = null;
                if (eventJson.ContainsKey("eventData"))
                {
                    eventData = eventJson["eventData"];
                }

                Dictionary <string, object> eventDataJson = null;
                if (eventData != null)
                {
                    eventDataJson = (Dictionary <string, object>)eventData;
                }

                externalDelegate.HandleHelpshiftEvent(eventName, eventDataJson);
            }
            else if (methodName == HelpshiftEventConstants.AuthenticationFailed)
            {
                Dictionary <string, object> failureReasonJson = (Dictionary <string, object>)Json.Deserialize(parametersJson);
                object failureReasonObject = failureReasonJson["reason"];
                int    failureReason       = System.Convert.ToInt32(failureReasonObject);

                HelpshiftAuthenticationFailureReason authFailureReason = HelpshiftAuthenticationFailureReason.UNKNOWN;

                if (failureReason == 0) // Auth token not provided
                {
                    authFailureReason = HelpshiftAuthenticationFailureReason.AUTH_TOKEN_NOT_PROVIDED;
                }
                else if (failureReason == 1) // Invalid auth token
                {
                    authFailureReason = HelpshiftAuthenticationFailureReason.INVALID_AUTH_TOKEN;
                }


                externalDelegate.AuthenticationFailedForUser(authFailureReason);
            }
        }