mirror of
https://github.com/YACReader/yacreader
synced 2025-07-14 02:54:46 -04:00
Implemented YACReaderHttpSessionStore.
This commit is contained in:
@ -1,6 +1,42 @@
|
||||
#include "yacreader_http_session_store.h"
|
||||
|
||||
YACReaderHttpSessionStore::YACReaderHttpSessionStore(QObject *parent) : QObject(parent)
|
||||
{
|
||||
#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::setYACReaderHttpSession(const QByteArray &httpSessionId, YACReaderHttpSession *yacreaderHttpSession)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
sessions.insert(httpSessionId, yacreaderHttpSession);
|
||||
}
|
||||
|
||||
YACReaderHttpSession *YACReaderHttpSessionStore::getYACReaderSessionHttpSession(const QByteArray &httpSessionId)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
return sessions.value(id, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user