Exemple #1
0
QByteArray IpcChannel::receiveMessage(int timeoutMsecs)
{
    disconnect(m_socket, SIGNAL(readyRead()), 0, 0);
#   ifdef _WIN32
    // Win32 workaround - see waitForDisconnected()
    QElapsedTimer timer;
    timer.start();
    while (m_socket->state() != QLocalSocket::UnconnectedState &&
           (timeoutMsecs == -1 || timer.elapsed() < timeoutMsecs))
    {
        QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
        milliSleep(1);
        if (appendCurrentMessage())
        {
            QByteArray msg = m_message;
            clearCurrentMessage();
            return msg;
        }
    }
#   else
    while (m_socket->waitForReadyRead(timeoutMsecs))
    {
        if (appendCurrentMessage())
        {
            QByteArray msg = m_message;
            clearCurrentMessage();
            return msg;
        }
    }
#   endif
    throw DisplazError("Could not read message from socket: %s",
                       m_socket->errorString());
}
Exemple #2
0
/// Read and emit messages until data runs out
void IpcChannel::readReadyData()
{
    while (appendCurrentMessage())
    {
        emit messageReceived(m_message);
        clearCurrentMessage();
    }
}
Exemple #3
0
QByteArray IpcChannel::receiveMessage(int timeoutMsecs)
{
    disconnect(m_socket, SIGNAL(readyRead()), 0, 0);
    while (m_socket->waitForReadyRead(timeoutMsecs))
    {
        if (appendCurrentMessage())
        {
            QByteArray msg = m_message;
            clearCurrentMessage();
            return msg;
        }
    }
    throw DisplazError("Could not read message from socket: %s",
                       m_socket->errorString());
    connect(m_socket, SIGNAL(readyRead()), this, SLOT(readReadyData()));
}