示例#1
0
void VoiceEndpoint::timerEvent(QTimerEvent *event)
{
    if(m_sesTimer > 0 && event && event->timerId() == m_sesTimer) {
        killTimer(m_sesTimer);
        m_sesTimer = 0;
        switch (m_sesPhase) {
        case PhSetupRequest:
            sessionSetupResponse(ResTimeout,QUuid());
            break;
        case PhSetupComplete:
            sessionSetupResponse(ResInvalidMessage,QUuid());
            break;
        case PhAudioStarted:
            stopAudioStream(m_sessId);
            break;
        case PhAudioStopped:
            //transcriptionResponse(ResTimeout,QList<Sentence>(),QUuid()); // We should actualy reply like this but lets do...
            transcriptionResponse(ResSuccess,
                            QList<Sentence>({
                                Sentence({8,QList<Word>({{1,2,"No"},{1,3,"one"},{1,5,"dared"},{1,2,"to"},{1,5,"reply"},{1,1,"."},{1,7,"Service"},{1,7,"Timeout"}})})
                            }),
                            m_appUuid); // Example transcription - for the reference
            break;
        case PhResultReceived:
            sendDictationResults();
            sessionDestroy();
            break;
        default:
            qDebug() << "Unhandled timer event for phase" << m_sesPhase;
        }
    }
}
示例#2
0
文件: session.c 项目: Quinchu/R1EMU
Session *sessionNew (RouterId_t routerId, uint8_t *sessionKey) {
    Session *self;

    if ((self = calloc(1, sizeof(Session))) == NULL) {
        return NULL;
    }

    if (!sessionInit(self, routerId, sessionKey)) {
        sessionDestroy(&self);
        error("Session failed to initialize.");
        return NULL;
    }

    return self;
}
示例#3
0
void VoiceEndpoint::sessionSetupResponse(Result result, const QUuid &appUuid)
{
    if(m_sessId>0) {
        qDebug() << "Sending session setup result" << result << "at session" << m_sessId << "of type" << m_sesType << "with app" << appUuid;
        quint32 flags = appUuid.isNull()?0:FlagAppInitiated;
        QByteArray pkt;
        WatchDataWriter writer(&pkt);
        pkt.append((quint8)CmdSessionSetup);
        writer.writeLE<quint32>(flags);
        pkt.append((quint8)m_sesType);
        pkt.append((quint8)result);
        m_watchConnection->writeToPebble(WatchConnection::EndpointVoiceControl,pkt);
        m_sesPhase = PhSetupComplete;
        if(result != ResSuccess) {
            sessionDestroy();
        } else {
            if(m_sesTimer)
                killTimer(m_sesTimer);
            m_sesTimer = startTimer(6000);
        }
    }
}