Webdar 1.0.0
Web user interface to libdar
Classes | Public Member Functions | Static Public Member Functions | List of all members
session Class Reference

class session - holds information about a current user session More...

#include <session.hpp>

Inheritance diagram for session:
Inheritance graph
[legend]
Collaboration diagram for session:
Collaboration graph
[legend]

Classes

struct  session_summary
 summary information of sessions More...
 

Public Member Functions

virtual answer give_answer (const request &req) override
 inherited from responder More...
 
bool has_waiting_threads () const
 
bool has_working_server () const
 
std::string get_session_ID () const
 
bool disconnection_requested () const
 
virtual void on_event (const std::string &event_name) override
 inherited from actor parent class More...
 
- Public Member Functions inherited from responder
 responder (const responder &ref)=default
 
 responder (responder &&ref) noexcept=default
 
responderoperator= (const responder &ref)=default
 
responderoperator= (responder &&ref) noexcept=default
 
void set_prefix (const chemin &chem)
 used for body_builder object for they have a proper prefix in path
 
const cheminget_prefix () const
 get the recorded URI path prefix for body_builder root hierarchy
 
virtual answer give_answer (const request &req)=0
 provides a standard mean for inherited class to provide answer to requests More...
 
- Public Member Functions inherited from actor
 actor (const actor &ref)=default
 
 actor (actor &&ref) noexcept(false)=default
 
actoroperator= (const actor &ref)=default
 
actoroperator= (actor &&ref) noexcept(false)
 
virtual void on_event (const std::string &event_name)=0
 implementation in inherited class of the action triggered by the event given in argument More...
 
- Public Member Functions inherited from reference
 reference ()
 usual constructor
 
 reference (const reference &ref)
 copy constructor More...
 
 reference (reference &&ref) noexcept(false)
 move constructor (only operational for objects without peering) More...
 
referenceoperator= (const reference &ref)
 assignment operator (only operational for objects without peering) More...
 
referenceoperator= (reference &&ref) noexcept(false)
 move assigment operator More...
 
virtual ~reference ()
 destructor
 
void peer_with (reference *obj)
 method used to create a relation between two objects More...
 
void break_peer_with (reference *obj)
 break the peering with the object given as argument
 
bool is_peer (reference *obj) const
 whether a peering exists with that object
 
bool is_empty () const
 whether the current object has peering
 
unsigned int size () const
 the number of peers
 

Static Public Member Functions

static bool create_new_session (const std::string &user, bool initial, const request &req, answer &ret)
 create a new session More...
 
static unsigned int get_num_session ()
 get the total number of session (all users)
 
static unsigned int get_num_session (const std::string &user)
 get the total number of session for the given user
 
static std::vector< session_summaryget_summary ()
 get a summary description vector of all sessions
 
static bool get_session_info (const std::string &session_ID, session_summary &val)
 get a summary description of the session known from its session_ID
 
static sessionacquire_session (const std::string &session_ID)
 acquire the excusivity use of the session which id is provided in argument More...
 
static void release_session (session *sess)
 release the session object from our exclusive access More...
 
static bool close_session (const std::string &session_ID)
 request the session to be tear down and destoyed More...
 

Additional Inherited Members

- Protected Member Functions inherited from responder
virtual void prefix_has_changed ()
 hook for inherited class, when the body builder object had its prefix changed More...
 
- Protected Member Functions inherited from reference
virtual void broken_peering_from (reference *obj)
 to be informed when a peer has broke the peering with me More...
 
void reset_read_peers () const
 reset the peers reading
 
bool read_next_peer (reference *&peer) const
 

Detailed Description

class session - holds information about a current user session

a session object stores a work under progress. An internal mutex avoids two concurrent requests to be addressed to a given session object. Session object are sollicitated by 'server' objects which only live during a TCP connection. Several TCP connection can connect over time or in concurrency to a given session object but only one at a time handles (acquired) the session.

Member Function Documentation

◆ acquire_session()

session * session::acquire_session ( const std::string &  session_ID)
static

acquire the excusivity use of the session which id is provided in argument

Parameters
[in]session_IDthe session to acquire
Returns
a pointer to the session object (it is managed by the session class, this not to be released)
Note
the call is blocking until the session is acquired. It has to be released when requested by other thread and/or when no more needed (browser disconnectio...) using the release_session() method

◆ close_session()

bool session::close_session ( const std::string &  session_ID)
static

request the session to be tear down and destoyed

Returns
true if the session exists and has been flagged for destruction, false if the session is unknown.

◆ create_new_session()

bool session::create_new_session ( const std::string &  user,
bool  initial,
const request req,
answer ret 
)
static

create a new session

Parameters
[in]userthe user to whom the session will belong
[in]initialif set to true a session is created only if no other session exist for that user
[in]reqthe request from the browser
[out]retthe answer to send back to the browser, this field is set only when this method returns true
Returns
true if a session has been created and only then provides the answer (ret) to return to the brownser
Note
this call may throw exception (if for example the session max number has been reached)

◆ give_answer()

answer session::give_answer ( const request req)
overridevirtual

inherited from responder

Implements responder.

◆ on_event()

void session::on_event ( const std::string &  event_name)
overridevirtual

inherited from actor parent class

Implements actor.

◆ release_session()

void session::release_session ( session sess)
static

release the session object from our exclusive access

Note
the session object should not be used anymore after that and before a new call to acquire_session() nor should the object be deleted/freed.

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