This commit is contained in:
Luis Ángel San Martín
2017-08-26 16:54:10 +02:00
parent 8b20014cc8
commit f149f314e0
105 changed files with 4145 additions and 2089 deletions

View File

@ -0,0 +1,44 @@
#include "yacreader_http_session_store.h"
#include "yacreader_http_session.h"
#include "httpsessionstore.h"
YACReaderHttpSessionStore::YACReaderHttpSessionStore(HttpSessionStore *sessionStore, QObject *parent)
: QObject(parent), sessionStore(sessionStore)
{
connect(&cleanupTimer,SIGNAL(timeout()),this,SLOT(sessionTimerEvent()));
cleanupTimer.start(60000);
}
void YACReaderHttpSessionStore::addYACReaderHttpSession(const QByteArray &httpSessionId, YACReaderHttpSession *yacreaderHttpSession)
{
QMutexLocker locker(&mutex);
sessions.insert(httpSessionId, yacreaderHttpSession);
}
YACReaderHttpSession *YACReaderHttpSessionStore::getYACReaderSessionHttpSession(const QByteArray &httpSessionId)
{
QMutexLocker locker(&mutex);
return sessions.value(httpSessionId, nullptr);
}
void YACReaderHttpSessionStore::sessionTimerEvent()
{
QMutexLocker locker(&mutex);
for(const QByteArray &id : sessions.keys())
{
if(sessionStore->getSession(id).isNull())
{
YACReaderHttpSession *session = sessions.value(id, nullptr);
if(session != nullptr)
delete session;
sessions.remove(id);
}
}
}