示例#1
0
/** Processes all message received on socket */
void PreviewSubscribe::processSocketMessage(const QList<QByteArray> &messageList)
{
    Container &rx = m_socketRx;

    if (messageList.length() < 2)  // in case we received insufficient data
    {
        return;
    }

    // we only handle the first two messges
    const auto &topic = messageList.first();
    rx.ParseFromArray(messageList.last().data(), messageList.last().size());

#ifdef QT_DEBUG
    std::string s;
    gpb::TextFormat::PrintToString(rx, &s);
    DEBUG_TAG(3, m_debugName, "received message" << QString::fromStdString(s));
#endif

    // react to any incoming message

    if (m_state == State::Up)
    {
        emit fsmUpMessageReceived(QPrivateSignal());
    }

    emit socketMessageReceived(topic, rx);
}
示例#2
0
/** Processes all message received on socket */
void StatusSubscribe::processSocketMessage(const QList<QByteArray> &messageList)
{
    Container &rx = m_socketRx;

    if (messageList.length() < 2)  // in case we received insufficient data
    {
        return;
    }

    // we only handle the first two messges
    const auto &topic = messageList.first();
    rx.ParseFromArray(messageList.last().data(), messageList.last().size());

#ifdef QT_DEBUG
    std::string s;
    gpb::TextFormat::PrintToString(rx, &s);
    DEBUG_TAG(3, m_debugName, "received message" << QString::fromStdString(s));
#endif

    // react to any incoming message

    if (m_state == State::Up)
    {
        emit fsmUpAnyMsgReceived(QPrivateSignal());
    }

    // react to ping message
    if (rx.type() == MT_PING)
    {
        return; // ping is uninteresting
    }

    // react to emcstat full update message
    else if (rx.type() == MT_EMCSTAT_FULL_UPDATE)
    {
        if (rx.has_pparams())
        {
            ProtocolParameters pparams = rx.pparams();
            m_heartbeatInterval = pparams.keepalive_timer();
        }

        if (m_state == State::Trying)
        {
            emit fsmTryingFullUpdateReceived(QPrivateSignal());
        }
    }

    emit socketMessageReceived(topic, rx);
}