示例#1
0
/// Routes the message to a remote or local destination
CMsg CMsgObjectInfo::Send( CMsg &x_rMsg )
{
    // Sanity check
    if ( !x_rMsg.IsValid() )
        return CMsg();

    // Can't be routed without an id
    if ( guid::CmpGuid( &IID_ZEROS, &x_rMsg.Mi().Dst()->GetId() ) )
        return CMsg();

    // Set our id in the return address
    x_rMsg.Mi().Src()->SetInstance( &m_guidId );

    // Is it for us?
    if ( guid::CmpGuid( &IID_ZEROS, &x_rMsg.Mi().Dst()->GetInstance() )
         || guid::CmpGuid( &m_guidId, &x_rMsg.Mi().Dst()->GetInstance() ) )
    {   
        // Short circuit the reply queue if needed
        if ( x_rMsg.Mi().WantReply() )
        {
            // Create reply signal
            x_rMsg.EnableReplyEvent( oexTRUE );

            // Set direct reply flag
            x_rMsg.SetDirectReply( oexTRUE );

        } // end if

        // Receive the message
        Recv( x_rMsg );
        
        return x_rMsg;

    } // end if

    // Send through the network
    return oexNet.Send( x_rMsg );
}
示例#2
0
CMsg CMsgObjectInfo::Execute( CMsg &x_rMsg )
{
    // Lock the handler list
    CTlLocalLock ll( m_lockMsgHandlers );
    if ( !ll.IsLocked() )
        return CMsg();

    // See if we have a destination for this address
    CMsgTarget mt = m_lstMsgHandlers[ x_rMsg.Mi().Dst()->GetId() ];
    if ( !mt.IsValid() )
        return CMsg();

    return mt( x_rMsg );
}
示例#3
0
oexBOOL CMsgObjectInfo::Recv( CMsg &x_rMsg )
{
    // Sanity check
    if ( !x_rMsg.IsValid() )
        return oexFALSE;

    // Can't route without an id
    if ( guid::CmpGuid( &IID_ZEROS, &x_rMsg.Mi().Dst()->GetId() ) )
        return oexFALSE;

    // Lock the handler list
    CTlLocalLock ll( m_lockMsgQueue );
    if ( !ll.IsLocked() )
        return oexFALSE;

    // Grab the priority
    oexUINT uPriority = x_rMsg.GetPriority();

    // Lowest priority?
    if ( !uPriority )
        m_lstMsgQueue.Append( x_rMsg );

    else
    {
        // Priority based insert
        oexBOOL bInserted = oexFALSE;
        for ( t_MsgQueue::iterator itInsert; 
              !bInserted && m_lstMsgQueue.Next( itInsert ); )
        {
            // Look for a lower priority object
            if ( itInsert.Obj().GetPriority() < uPriority )
            {
                // Put the command ahead of this item
                t_MsgQueue::iterator it = m_lstMsgQueue.Append( x_rMsg );
                
                // Did we get a valid object?
                if ( it.IsValid() )
                {
                    // Move to correct location
                    m_lstMsgQueue.MoveBefore( it, itInsert );

                    // Check the result
                    bInserted = oexTRUE;

                } // end if

            } // end if

        } // end for

        // Just stick it on the end if we couldn't find a spot
        if ( !bInserted )
            m_lstMsgQueue.Append( x_rMsg );

    } // end else

    // Set event if message is in the queue
    if ( m_lstMsgQueue.Size() )
        m_evMsgWaiting.Set();

    // Hand down
    return oexTRUE;
}