| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #include "autoheartbeat.h"
- #include "respheartbeat.h"
- #include "sncdatabase.h"
- AutoHeartBeat::AutoHeartBeat(QObject *parent) :
- QThread(parent)
- {
- m_numchk = new WSNumChk();
- m_refreshStamp = "";
- }
- AutoHeartBeat::~AutoHeartBeat()
- {
- m_numchk->abort();
- delete m_numchk;
- qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
- <<"FormNumchk.AutoHeartBeat Destroyed.";
- }
- void AutoHeartBeat::abort()
- {
- m_numchk->abort();
- }
- void AutoHeartBeat::setAccountInfo(QMap<QString, QString> accountInfo)
- {
- m_account = accountInfo;
- }
- void AutoHeartBeat::setHost(QString host, QString port)
- {
- m_host = host;
- m_port = port;
- m_numchk->setHost(m_host,m_port);
- }
- void AutoHeartBeat::run()
- {
- QString src = "SNC-" + SNCDataBase::getAppVersion();
- QString userHash = m_account.value("userhash");
- if(userHash.isEmpty())
- return ;
- QString json = m_numchk->heartBeat(userHash,src,m_refreshStamp);
- RespHeartBeat response(json);
- if(response.getRtnCode()==1)
- {
- m_refreshStamp = response.getRefreshStamp();
- QString refreshParam = response.getRefreshParam();
- if(refreshParam.left(1)=="1")
- {
- emit userStateChanged();
- }
- }
- }
|