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)
{
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())
{
qDebug() << Q_FUNC_INFO << "flag=true, calling makeDisconnect()";
makeDiconnect();
}
qDebug() << Q_FUNC_INFO << "Connection to: " << server << "On Port: " << port;
connectToHostEncrypted(server.toStdString().c_str(), port);
loop.exec(); //starting connection, waiting to encryption and then it ends
qDebug() << Q_FUNC_INFO << "returning the connection status: " << isConnected();
if (reConnection)
{
reConnection = false;
emit serverDisconnectedbyRemote();
}
return isConnected();
}

View file

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

View file

@ -9,6 +9,7 @@ jceLogin::jceLogin(user * username)
this->recieverPage = new QString();
this->jceA = username;
this->JceConnector = new jceSSLClient();
JceConnector->connect(JceConnector,SIGNAL(serverDisconnectedbyRemote()),this,SLOT(reValidation()));
}
jceLogin::~jceLogin()
@ -287,3 +288,14 @@ QString jceLogin::getPage()
{
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 "jceLoginHtmlScripts.h"
#include <QObject>
#include <QString>
class jceLogin
{
Q_OBJECT
public:
jceLogin() {}
jceLogin(user* username);
~jceLogin();
enum jceStatus {
JCE_NOT_CONNECTED,
@ -26,8 +34,7 @@ public:
JCE_GRADE_PAGE_PASSED
};
jceLogin(user* username);
~jceLogin();
void makeConnection() throw (jceStatus);
void reConnect() throw (jceStatus);
@ -41,6 +48,9 @@ public:
QString getPage();
private slots:
void reValidation();
private:
int makeFirstVisit();