ofxHTTP
A collection of tools for HTTP.
ofx::HTTP::SimpleSessionStore Class Reference

An in-memory session store. More...

#include <SessionStore.h>

Inheritance diagram for ofx::HTTP::SimpleSessionStore:
ofx::HTTP::BaseSessionStore ofx::HTTP::AbstractSessionStore

Public Member Functions

 SimpleSessionStore (const std::string &sessionKeyName)
 
- Public Member Functions inherited from ofx::HTTP::BaseSessionStore
 BaseSessionStore (const std::string &sessionKeyName)
 
AbstractSessiongetSession (Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response)
 Get a valid session for the given request. More...
 
void destroySession (Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response)
 Destroy the session(s) associated with the given exchange. More...
 
- Public Member Functions inherited from ofx::HTTP::AbstractSessionStore
virtual ~AbstractSessionStore ()
 Destroy the AbstractSessionStore.
 

Protected Types

typedef std::map< std::string, std::shared_ptr< AbstractSession > > SessionMap
 

Protected Member Functions

 SimpleSessionStore (const SimpleSessionStore &)
 
SimpleSessionStoreoperator= (const SimpleSessionStore &)
 
bool hasSession (const std::string &sessionId) const override
 Query if the store has the the given session. More...
 
AbstractSessiongetSession (const std::string &sessionId) override
 Get a session by sesssionId. More...
 
AbstractSessioncreateSession () override
 Create a completely new session. More...
 
void destroySession (const std::string &sessionId) override
 Destroy the record of a session by its session id. More...
 

Protected Attributes

SessionMap _sessionMap
 
std::mutex _mutex
 
- Protected Attributes inherited from ofx::HTTP::BaseSessionStore
const std::string _sessionKeyName
 

Additional Inherited Members

- Static Public Attributes inherited from ofx::HTTP::BaseSessionStore
static const std::string DEFAULT_SESSION_KEY_NAME = "session_key"
 

Detailed Description

An in-memory session store.

Member Function Documentation

◆ createSession()

AbstractSession & ofx::HTTP::SimpleSessionStore::createSession ( )
overrideprotectedvirtual

Create a completely new session.

Since this returns a reference, the newly created session must be stored outside of the local method scope so the reference does not become invalid.

Returns
A reference to the newly created session.

Implements ofx::HTTP::BaseSessionStore.

◆ destroySession()

void ofx::HTTP::SimpleSessionStore::destroySession ( const std::string &  sessionId)
overrideprotectedvirtual

Destroy the record of a session by its session id.

If session data does not exist, the method will return quietly.

Parameters
sessionIdThe id of the session to destroy.

Implements ofx::HTTP::BaseSessionStore.

◆ getSession()

AbstractSession & ofx::HTTP::SimpleSessionStore::getSession ( const std::string &  sessionId)
overrideprotectedvirtual

Get a session by sesssionId.

Parameters
sessionIdThe id of the session to get.
Exceptions
Poco::InvalidAccessExceptionif no session is found.

Implements ofx::HTTP::BaseSessionStore.

◆ hasSession()

bool ofx::HTTP::SimpleSessionStore::hasSession ( const std::string &  sessionId) const
overrideprotectedvirtual

Query if the store has the the given session.

Parameters
sessionIdThe id of the session to query.

Implements ofx::HTTP::BaseSessionStore.


The documentation for this class was generated from the following files: