#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()<abort(); } void AutoHeartBeat::setAccountInfo(QMap 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(); } } }