Exemple #1
0
        private void GetOperationSuccessEventHandler(Operation operation)
        {
#if !NET_2_0 && !NET_2_0_SUBSET
            GetOperationSuccessEvent?.Invoke(operation);
#else
            if (GetOperationSuccessEvent != null)
            {
                GetOperationSuccessEvent(operation);
            }
#endif
        }
Exemple #2
0
        private void NetworkResponseEventHandler(NetworkResponse response)
        {
            if (response.HasError() && GCSpeechRecognition.Instance.isFullDebugLogIfError)
            {
                Debug.LogError(response.GetFullLog());
            }

            if (response.Parameters.Length > 0)
            {
                Enumerators.ApiType apiType = (Enumerators.ApiType)response.Parameters[0];

                switch (apiType)
                {
                case Enumerators.ApiType.RECOGNIZE:
                {
                    if (response.HasError())
                    {
#if !NET_2_0 && !NET_2_0_SUBSET
                        RecognizeFailedEvent?.Invoke(response.GetFullLog());
#else
                        if (RecognizeFailedEvent != null)
                        {
                            RecognizeFailedEvent(response.GetFullLog());
                        }
#endif
                    }
                    else
                    {
#if !NET_2_0 && !NET_2_0_SUBSET
                        RecognizeSuccessEvent?.Invoke(JsonConvert.DeserializeObject <RecognitionResponse>(response.Response));
#else
                        if (RecognizeSuccessEvent != null)
                        {
                            RecognizeSuccessEvent(JsonConvert.DeserializeObject <RecognitionResponse>(response.Response));
                        }
#endif
                    }
                }
                break;

                case Enumerators.ApiType.LONG_RUNNING_RECOGNIZE:
                {
                    if (response.HasError())
                    {
#if !NET_2_0 && !NET_2_0_SUBSET
                        LongRunningRecognizeFailedEvent?.Invoke(response.GetFullLog());
#else
                        if (LongRunningRecognizeFailedEvent != null)
                        {
                            LongRunningRecognizeFailedEvent(response.GetFullLog());
                        }
#endif
                    }
                    else
                    {
#if !NET_2_0 && !NET_2_0_SUBSET
                        LongRunningRecognizeSuccessEvent?.Invoke(JsonConvert.DeserializeObject <Operation>(response.Response));
#else
                        if (LongRunningRecognizeSuccessEvent != null)
                        {
                            LongRunningRecognizeSuccessEvent(JsonConvert.DeserializeObject <Operation>(response.Response));
                        }
#endif
                    }
                }
                break;

                case Enumerators.ApiType.LIST_OPERATIONS:
                {
                    if (response.HasError())
                    {
#if !NET_2_0 && !NET_2_0_SUBSET
                        ListOperationsFailedEvent?.Invoke(response.GetFullLog());
#else
                        if (ListOperationsFailedEvent != null)
                        {
                            ListOperationsFailedEvent(response.GetFullLog());
                        }
#endif
                    }
                    else
                    {
#if !NET_2_0 && !NET_2_0_SUBSET
                        ListOperationsSuccessEvent?.Invoke(JsonConvert.DeserializeObject <ListOperationsResponse>(response.Response));
#else
                        if (ListOperationsSuccessEvent != null)
                        {
                            ListOperationsSuccessEvent(JsonConvert.DeserializeObject <ListOperationsResponse>(response.Response));
                        }
#endif
                    }
                }
                break;

                case Enumerators.ApiType.OPERATION:
                {
                    if (response.HasError())
                    {
#if !NET_2_0 && !NET_2_0_SUBSET
                        GetOperationFailedEvent?.Invoke(response.GetFullLog());
#else
                        if (GetOperationFailedEvent != null)
                        {
                            GetOperationFailedEvent(response.GetFullLog());
                        }
#endif
                    }
                    else
                    {
#if !NET_2_0 && !NET_2_0_SUBSET
                        GetOperationSuccessEvent?.Invoke(JsonConvert.DeserializeObject <Operation>(response.Response));
#else
                        if (GetOperationSuccessEvent != null)
                        {
                            GetOperationSuccessEvent(JsonConvert.DeserializeObject <Operation>(response.Response));
                        }
#endif
                    }
                }
                break;

                default: break;
                }
            }
        }