Exemple #1
0
        private void ConverseResp(RESTConnector.Request req, RESTConnector.Response resp)
        {
            ConverseResponse response = new ConverseResponse();

            if (resp.Success)
            {
                try
                {
                    fsData   data = null;
                    fsResult r    = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data);
                    if (!r.Succeeded)
                    {
                        throw new WatsonException(r.FormattedMessages);
                    }

                    object obj = response;
                    r = sm_Serializer.TryDeserialize(data, obj.GetType(), ref obj);
                    if (!r.Succeeded)
                    {
                        throw new WatsonException(r.FormattedMessages);
                    }
                }
                catch (Exception e)
                {
                    Log.Error("Natural Language Classifier", "ConverseResp Exception: {0}", e.ToString());
                    resp.Success = false;
                }
            }

            if (((ConverseReq)req).Callback != null)
            {
                ((ConverseReq)req).Callback(resp.Success ? response : null);
            }
        }
Exemple #2
0
 private void OnDialog(ConverseResponse resp)
 {
     if (m_DialogCount > 0)
     {
         m_DialogCount -= 1;
         if (resp != null)
         {
             if (m_DialogCount == 0 && m_Callback != null && m_Callback.Target != null)
             {
                 m_Callback(SERVICE_ID, true);
             }
         }
         else
         {
             OnFailure("ConverseResponse is null.");
         }
     }
 }