void Jumpropes::ThreadedConnection::execute() {
    if ( socket->receive( sMessage ) ) {
        if ( sMessage->getLength() > 0 ) {
            newMessageReceived( sMessage );
        }
    } else {
        stop();
    }
}
示例#2
0
//!
//! \brief IrcConnection::parseLines Parses read lines from the server.
//!
//! This method emits:
//!
//!   * IrcConnection::newMessageReceived(IrcMessage *)
//!
void IrcConnection::parseLines()
{
    QTimer::singleShot(0, this, [&]() {
        int index = -1;

        while ((index = _recvbuf.indexOf("\r\n")) != -1) {
            auto content = _recvbuf.left(index);
            _recvbuf = _recvbuf.mid(index + 2);

            if (IrcMessage *msg = _parser->parseLine(content)) {
                emit newMessageReceived(msg);
            }
    //        qDebug() << content;
        }
    });
}