Exemplo n.º 1
0
/*----------------------------------------------------------------------
|   PLT_HttpHelper::ParseBody
+---------------------------------------------------------------------*/
NPT_Result
PLT_HttpHelper::ParseBody(const NPT_HttpMessage& message, 
                          NPT_XmlElementNode*&   tree) 
{
    // reset tree
    tree = NULL;

    // read body
    NPT_String body;
    NPT_CHECK_WARNING(GetBody(message, body));

    // parse body
    NPT_XmlParser parser;
    NPT_XmlNode*  node;
    NPT_Result result = parser.Parse(body, node);
    if (NPT_FAILED(result)) {
        NPT_LOG_FINEST_1("Failed to parse %s", body.IsEmpty()?"(empty string)":body.GetChars());
        NPT_CHECK_WARNING(result);
    }
    
    tree = node->AsElementNode();
    if (!tree) {
        delete node;
        return NPT_FAILURE;
    }

    return NPT_SUCCESS;
}
Exemplo n.º 2
0
/*----------------------------------------------------------------------
|   NPT_SimpleMessageQueue::PumpMessage
+---------------------------------------------------------------------*/
NPT_Result
NPT_SimpleMessageQueue::PumpMessage(NPT_Timeout timeout /* = NPT_TIMEOUT_INFINITE */)
{
    NPT_SimpleMessageCapsule* capsule;
    
    NPT_LOG_FINEST_1("popping message from queue, timeout=%d", timeout);
    NPT_Result result = m_Queue.Pop(capsule, timeout);
    if (NPT_SUCCEEDED(result) && capsule) {
        if (capsule->m_Handler && capsule->m_Message) {
            result = capsule->m_Handler->HandleMessage(capsule->m_Message);
        }
        delete capsule->m_Message;
        delete capsule;
    } else {
        NPT_LOG_FINEST_1("m_Queue.Pop() returned %d", result);
    }

    return result;
}