Example #1
0
//=============================================================================
// METHOD: SPELLipcIncomingRequest:run
//=============================================================================
void SPELLipcIncomingRequest::run()
{
    std::string senderId = m_message->getSender();
    std::string receiverId = m_message->getReceiver();
    // If the request has been canceled beforehand
    if (m_cancel) return;
    SPELLipcMessage* response = m_listener->processRequest(m_message);
    if (response && !m_cancel)
    {
        response->setSender(receiverId);
        response->setReceiver(senderId);
        // Do not set sequence number if it is already set.
        // This happens when forwarding requests.
        if (response->getSequence() == -1)
        {
            response->setSequence( m_message->getSequence() );
        }
        try
        {
            if (m_interface->isConnected())
            {
                SPELLipcOutput& writer = m_interface->getWriter(m_message->getKey());
                writer.send(response);
                m_interface->endRequest( getThreadId() );
            }
        }
        catch(...) {};
        delete response;
    }
    finish();
    delete m_message;
}
Example #2
0
//=============================================================================
// METHOD: SPELLserverCif::processRequest
//=============================================================================
SPELLipcMessage* SPELLserverCif::processRequest( SPELLipcMessage* msg )
{
    std::string requestId = msg->getId();
    std::string procId = msg->get(MessageField::FIELD_PROC_ID);
    SPELLipcMessage* response = new SPELLipcMessage( msg->getId() );
    response->setType(MSG_TYPE_RESPONSE);
    response->setReceiver( msg->getSender() );
    response->setSender( msg->getReceiver() );

    if (requestId == ExecutorMessages::REQ_GET_CONFIG)
    {
        m_processor.processGetConfig(msg,response);
    }
    else if (requestId == ExecutorMessages::REQ_SET_CONFIG)
    {
        m_processor.processSetConfig(msg,response);
    }
    else if (requestId == ExecutorMessages::REQ_SET_BREAKPOINT)
    {
        m_processor.processSetBreakpoint(msg, response);
    }
    else if (requestId == ExecutorMessages::REQ_CLEAR_BREAKPOINT)
    {
        m_processor.processClearBreakpoints(msg, response);
    }
    else if (requestId == ExecutorMessages::REQ_VARIABLE_NAMES)
    {
        m_processor.processGetVariables(msg, response);
    }
    else if (requestId == ExecutorMessages::REQ_VARIABLE_WATCH)
    {
        m_processor.processVariableWatch(msg, response);
    }
    else if (requestId == ExecutorMessages::REQ_VARIABLE_NOWATCH)
    {
        m_processor.processVariableNoWatch(msg, response);
    }
    else if (requestId == ExecutorMessages::REQ_WATCH_NOTHING)
    {
        m_processor.processWatchNothing(msg, response);
    }
    else if (requestId == ExecutorMessages::REQ_CHANGE_VARIABLE)
    {
        m_processor.processChangeVariable(msg, response);
    }
    else if (msg->getType() == MSG_TYPE_NOTIFY)
    {
        if (procId != SPELLexecutor::instance().getProcId())
        {
            m_processor.processNotificationForChild(msg,response);
        }
        else
        {
            LOG_ERROR("[CIF] Unexpected message for executor " + procId);
        }
    }
    else
    {
        LOG_ERROR("[CIF] Unprocessed request: " + requestId)
    }
    return response;
}