The following definitions:
ServerThread.h:
....
private slots:
void onReadyRead();
....
....
private slots:
void sendMessage(const QString &msg, const QVariant &data);
void onReadyRead();
void onMessage(const QString &msg, const QVariant &data);
....
To copy to clipboard, switch view to plain text mode
ServerThread.cpp:
void ServerThread::onReadyRead() {
if (tcpSocket == NULL) return;
if (blockSize == 0) {
if (tcpSocket->bytesAvailable() < (int)sizeof(quint32)) return;
in >> blockSize;
reading_message = true;
}
if (tcpSocket->bytesAvailable() < blockSize) return;
in >> msgString;
in >> msgData;
emit onMessage( msgString, msgData );
reading_message = false;
blockSize = 0;
if (tcpSocket->bytesAvailable() > 0) onReadyRead();
}
{
qDebug() << "6. here OK ";
if( msg == SAP_RETR_WELCOME_STRING)
{
}
qDebug() << "7. here OK ";
....
void ServerThread::onReadyRead() {
if (tcpSocket == NULL) return;
if ( tcpSocket->state() != QAbstractSocket::ConnectedState ) return;
QDataStream in(tcpSocket);
in.setVersion(QDataStream::Qt_4_5);
if (blockSize == 0) {
if (tcpSocket->bytesAvailable() < (int)sizeof(quint32)) return;
in >> blockSize;
reading_message = true;
}
if (tcpSocket->bytesAvailable() < blockSize) return;
QString msgString;
QVariant msgData;
in >> msgString;
in >> msgData;
emit onMessage( msgString, msgData );
reading_message = false;
blockSize = 0;
if (tcpSocket->bytesAvailable() > 0) onReadyRead();
}
void ServerThread::onMessage(const QString &msg, const QVariant &data )
{
qDebug() << "6. here OK ";
if( msg == SAP_RETR_WELCOME_STRING)
{
}
qDebug() << "7. here OK ";
....
To copy to clipboard, switch view to plain text mode
Bookmarks