Beispiel #1
0
        private void MessageResp(RESTConnector.Request req, RESTConnector.Response resp)
        {
            DataModels.MessageResponse response = new DataModels.MessageResponse();
            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("Conversation", "MessageResp Exception: {0}", e.ToString());
                    resp.Success = false;
                }
            }

            if (((MessageReq)req).Callback != null)
            {
                ((MessageReq)req).Callback(resp.Success ? response : null);
            }
        }
Beispiel #2
0
 private void OnMessage(DataModels.MessageResponse resp)
 {
     if (m_ConversationCount > 0)
     {
         m_ConversationCount -= 1;
         if (resp != null)
         {
             if (m_ConversationCount == 0 && m_Callback != null && m_Callback.Target != null)
             {
                 m_Callback(SERVICE_ID, true);
             }
         }
         else
         {
             OnFailure("ConverseResponse is null.");
         }
     }
 }