server disconnection bug 1

This commit is contained in:
liranbg 2014-09-21 13:31:26 +03:00
parent ac0973cf11
commit 32e4272f83
4 changed files with 178 additions and 143 deletions

View file

@ -26,18 +26,31 @@ jceSSLClient::jceSSLClient() : flag(false), packet(""), networkConf(), reConnect
*/ */
bool jceSSLClient::makeConnect(QString server, int port) bool jceSSLClient::makeConnect(QString server, int port)
{ {
qDebug() << Q_FUNC_INFO << "Making connection"; if (reConnection) //reset reconnectiong flag
{
qDebug() << Q_FUNC_INFO << "Making Reconnection";
}
else
qDebug() << Q_FUNC_INFO << "Making Connection";
if (isConnected()) if (isConnected())
{ {
qDebug() << Q_FUNC_INFO << "flag=true, calling makeDisconnect()"; qDebug() << Q_FUNC_INFO << "flag=true, calling makeDisconnect()";
makeDiconnect(); makeDiconnect();
} }
qDebug() << Q_FUNC_INFO << "Connection to: " << server << "On Port: " << port; qDebug() << Q_FUNC_INFO << "Connection to: " << server << "On Port: " << port;
connectToHostEncrypted(server.toStdString().c_str(), port); connectToHostEncrypted(server.toStdString().c_str(), port);
loop.exec(); //starting connection, waiting to encryption and then it ends loop.exec(); //starting connection, waiting to encryption and then it ends
qDebug() << Q_FUNC_INFO << "returning the connection status: " << isConnected(); qDebug() << Q_FUNC_INFO << "returning the connection status: " << isConnected();
if (reConnection)
{
reConnection = false;
emit serverDisconnectedbyRemote();
}
return isConnected(); return isConnected();
} }

View file

@ -10,7 +10,7 @@
#define milisTimeOut 4000 #define milisTimeOut 4000
class jceSSLClient : QSslSocket class jceSSLClient : public QSslSocket
{ {
Q_OBJECT Q_OBJECT
public: public:

View file

@ -9,6 +9,7 @@ jceLogin::jceLogin(user * username)
this->recieverPage = new QString(); this->recieverPage = new QString();
this->jceA = username; this->jceA = username;
this->JceConnector = new jceSSLClient(); this->JceConnector = new jceSSLClient();
JceConnector->connect(JceConnector,SIGNAL(serverDisconnectedbyRemote()),this,SLOT(reValidation()));
} }
jceLogin::~jceLogin() jceLogin::~jceLogin()
@ -287,3 +288,14 @@ QString jceLogin::getPage()
{ {
return *recieverPage; return *recieverPage;
} }
void jceLogin::reValidation()
{
qDebug() << Q_FUNC_INFO << "Revalidating user";
if (makeFirstVisit())
{
if (makeSecondVisit())
qDebug() << Q_FUNC_INFO << "Validated";
}
}

View file

@ -5,11 +5,19 @@
#include "./src/jceSettings/user.h" #include "./src/jceSettings/user.h"
#include "jceLoginHtmlScripts.h" #include "jceLoginHtmlScripts.h"
#include <QObject>
#include <QString> #include <QString>
class jceLogin class jceLogin
{ {
Q_OBJECT
public: public:
jceLogin() {}
jceLogin(user* username);
~jceLogin();
enum jceStatus { enum jceStatus {
JCE_NOT_CONNECTED, JCE_NOT_CONNECTED,
@ -26,8 +34,7 @@ public:
JCE_GRADE_PAGE_PASSED JCE_GRADE_PAGE_PASSED
}; };
jceLogin(user* username);
~jceLogin();
void makeConnection() throw (jceStatus); void makeConnection() throw (jceStatus);
void reConnect() throw (jceStatus); void reConnect() throw (jceStatus);
@ -41,6 +48,9 @@ public:
QString getPage(); QString getPage();
private slots:
void reValidation();
private: private:
int makeFirstVisit(); int makeFirstVisit();