示例#1
0
文件: Services.cpp 项目: ihmc/nomads
int MessagingService::broadcastDataMessage (const char *pszMessageID, const char *pszTargetNodeId, int64 i64TimeOut,
                                            uint8 ui8Priority, bool bRequireAck, const char *pszLogMsg, const char *pszHints)
{
    if (_pDataCacheInterface == NULL) {
        return -7;
    }
    MessageHeader *pMH = _pDataCacheInterface->getMessageInfo (pszMessageID);
    if (pMH == NULL) {
        checkAndLogMsg ("MessagingService::sendMessage", Logger::L_Warning,
                        "Can not send message %s; MessageInfo could not be found/instantiated\n",
                        pszMessageID);
        return -6;
    }

    pMH->setPriority (ui8Priority);
    pMH->setAcknowledgment (bRequireAck);

    int rc = broadcastDataMessage (pMH, pszTargetNodeId, i64TimeOut, pszLogMsg, pszHints);
    _pDataCacheInterface->release (pMH->getMsgId(), pMH);
    return rc;
}
示例#2
0
void AckController::sendUnsentMessagesTo (MessageByTarget *pMBT, const char *pszTarget)
{
    const char *pszMethodName = "AckController::sendQueuedMessagesTo";

    MessageHeader *pMHTmp;
    MessageHeader *pMH = pMBT->unsentMessages.getFirst();
    while ((pMH != NULL) && (pMBT->unacknowledgedMessages.getCount() < _ui8TransmissionWindow)) {
        // send the message
        if (broadcastDataMessage (pMH, pszTarget, _i64TimeOut, "Sending queued message") == 0) {
            // and add it to the unacknowledged messages list
            pMBT->unacknowledgedMessages.put (pMH->getMsgId(),
                                              new MessageState (getTimeInMilliseconds(), _i64TimeOut));
            checkAndLogMsg (pszMethodName, Logger::L_Info,
                            "Transmission Window is %d, waiting for ack messages %d\n",
                            _ui8TransmissionWindow, pMBT->unacknowledgedMessages.getCount());
        }

        // remove the message from the queue of the unsent messages
        pMHTmp = pMBT->unsentMessages.getNext();
        pMH = pMBT->unsentMessages.remove (pMH);
        delete pMH;
        pMH = pMHTmp;
    }
}