diff --git a/Core/tcpclient.cpp b/Core/tcpclient.cpp index 06f8eff..5d7a54c 100644 --- a/Core/tcpclient.cpp +++ b/Core/tcpclient.cpp @@ -33,9 +33,11 @@ void TCPClient::SetConnect(ServerSettings *serverSettings) if(socket->state() != QTcpSocket::ConnectedState){ emit onSendDebugLog("Connect invalid"); + emit ConnectionState(false); return; }else{ emit onSendDebugLog("Connect complete"); + emit ConnectionState(true); } } @@ -44,6 +46,11 @@ void TCPClient::SendClientAutorization() QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); + if(socket->state() != QTcpSocket::ConnectedState){ + emit ConnectionState(false); + return; + } + QFile file(tempName); file.open(QIODevice::ReadOnly); diff --git a/Core/tcpclient.h b/Core/tcpclient.h index b716bd1..32b51e7 100644 --- a/Core/tcpclient.h +++ b/Core/tcpclient.h @@ -36,6 +36,7 @@ public: signals: void onSendDebugLog(QString message); void Recognize(QTcpSocket *socket); + void ConnectionState(bool flag); public slots: void MessageEntered(QString message); diff --git a/debug/moc_tcpclient.cpp b/debug/moc_tcpclient.cpp index 8ec2e21..77ab0ee 100644 --- a/debug/moc_tcpclient.cpp +++ b/debug/moc_tcpclient.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_TCPClient_t { - QByteArrayData data[9]; - char stringdata0[90]; + QByteArrayData data[11]; + char stringdata0[111]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -39,13 +39,16 @@ QT_MOC_LITERAL(3, 26, 7), // "message" QT_MOC_LITERAL(4, 34, 9), // "Recognize" QT_MOC_LITERAL(5, 44, 11), // "QTcpSocket*" QT_MOC_LITERAL(6, 56, 6), // "socket" -QT_MOC_LITERAL(7, 63, 14), // "MessageEntered" -QT_MOC_LITERAL(8, 78, 11) // "onReadyRead" +QT_MOC_LITERAL(7, 63, 15), // "ConnectionState" +QT_MOC_LITERAL(8, 79, 4), // "flag" +QT_MOC_LITERAL(9, 84, 14), // "MessageEntered" +QT_MOC_LITERAL(10, 99, 11) // "onReadyRead" }, "TCPClient\0onSendDebugLog\0\0message\0" "Recognize\0QTcpSocket*\0socket\0" - "MessageEntered\0onReadyRead" + "ConnectionState\0flag\0MessageEntered\0" + "onReadyRead" }; #undef QT_MOC_LITERAL @@ -55,24 +58,26 @@ static const uint qt_meta_data_TCPClient[] = { 8, // revision 0, // classname 0, 0, // classinfo - 4, 14, // methods + 5, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags - 2, // signalCount + 3, // signalCount // signals: name, argc, parameters, tag, flags - 1, 1, 34, 2, 0x06 /* Public */, - 4, 1, 37, 2, 0x06 /* Public */, + 1, 1, 39, 2, 0x06 /* Public */, + 4, 1, 42, 2, 0x06 /* Public */, + 7, 1, 45, 2, 0x06 /* Public */, // slots: name, argc, parameters, tag, flags - 7, 1, 40, 2, 0x0a /* Public */, - 8, 0, 43, 2, 0x08 /* Private */, + 9, 1, 48, 2, 0x0a /* Public */, + 10, 0, 51, 2, 0x08 /* Private */, // signals: parameters QMetaType::Void, QMetaType::QString, 3, QMetaType::Void, 0x80000000 | 5, 6, + QMetaType::Void, QMetaType::Bool, 8, // slots: parameters QMetaType::Void, QMetaType::QString, 3, @@ -89,8 +94,9 @@ void TCPClient::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, v switch (_id) { case 0: _t->onSendDebugLog((*reinterpret_cast< QString(*)>(_a[1]))); break; case 1: _t->Recognize((*reinterpret_cast< QTcpSocket*(*)>(_a[1]))); break; - case 2: _t->MessageEntered((*reinterpret_cast< QString(*)>(_a[1]))); break; - case 3: _t->onReadyRead(); break; + case 2: _t->ConnectionState((*reinterpret_cast< bool(*)>(_a[1]))); break; + case 3: _t->MessageEntered((*reinterpret_cast< QString(*)>(_a[1]))); break; + case 4: _t->onReadyRead(); break; default: ; } } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { @@ -120,6 +126,13 @@ void TCPClient::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, v return; } } + { + using _t = void (TCPClient::*)(bool ); + if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&TCPClient::ConnectionState)) { + *result = 2; + return; + } + } } } @@ -152,13 +165,13 @@ int TCPClient::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 4) + if (_id < 5) qt_static_metacall(this, _c, _id, _a); - _id -= 4; + _id -= 5; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 4) + if (_id < 5) qt_static_metacall(this, _c, _id, _a); - _id -= 4; + _id -= 5; } return _id; } @@ -176,5 +189,12 @@ void TCPClient::Recognize(QTcpSocket * _t1) void *_a[] = { nullptr, const_cast(reinterpret_cast(std::addressof(_t1))) }; QMetaObject::activate(this, &staticMetaObject, 1, _a); } + +// SIGNAL 2 +void TCPClient::ConnectionState(bool _t1) +{ + void *_a[] = { nullptr, const_cast(reinterpret_cast(std::addressof(_t1))) }; + QMetaObject::activate(this, &staticMetaObject, 2, _a); +} QT_WARNING_POP QT_END_MOC_NAMESPACE diff --git a/debug/moc_tcpclient.o b/debug/moc_tcpclient.o index 45f444a..a2f4488 100644 Binary files a/debug/moc_tcpclient.o and b/debug/moc_tcpclient.o differ diff --git a/debug/tcpclient.o b/debug/tcpclient.o index 23d9818..95c8e3b 100644 Binary files a/debug/tcpclient.o and b/debug/tcpclient.o differ