1 #include "yacreader_http_session_store.h"
2 
3 #include "yacreader_http_session.h"
4 
5 #include "httpsessionstore.h"
6 
7 using stefanfrings::HttpSessionStore;
8 
YACReaderHttpSessionStore(HttpSessionStore * sessionStore,QObject * parent)9 YACReaderHttpSessionStore::YACReaderHttpSessionStore(HttpSessionStore *sessionStore, QObject *parent)
10     : QObject(parent), sessionStore(sessionStore)
11 {
12     //sessions are no longer http sessions in v2, we need another mechanism for cleaning
13 
14     //connect(&cleanupTimer,SIGNAL(timeout()),this,SLOT(sessionTimerEvent()));
15     //cleanupTimer.start(60000);
16 }
17 
addYACReaderHttpSession(const QByteArray & httpSessionId,YACReaderHttpSession * yacreaderHttpSession)18 void YACReaderHttpSessionStore::addYACReaderHttpSession(const QByteArray &httpSessionId, YACReaderHttpSession *yacreaderHttpSession)
19 {
20     QMutexLocker locker(&mutex);
21 
22     sessions.insert(httpSessionId, yacreaderHttpSession);
23 }
24 
getYACReaderSessionHttpSession(const QByteArray & httpSessionId)25 YACReaderHttpSession *YACReaderHttpSessionStore::getYACReaderSessionHttpSession(const QByteArray &httpSessionId)
26 {
27     QMutexLocker locker(&mutex);
28 
29     return sessions.value(httpSessionId, nullptr);
30 }
31 
sessionTimerEvent()32 void YACReaderHttpSessionStore::sessionTimerEvent()
33 {
34     //sessions are no longer http sessions in v2, we are using a token, so sessionStore->getSession(id).isNull() is always true.
35     /*QMutexLocker locker(&mutex);
36     for(const QByteArray &id : sessions.keys())
37     {
38         if(sessionStore->getSession(id).isNull())
39         {
40             YACReaderHttpSession *session = sessions.value(id, nullptr);
41             if(session != nullptr)
42                 delete session;
43 
44             sessions.remove(id);
45         }
46     }*/
47 }
48