OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
Session Class Reference

#include "Session.h"

Public Member Functions

 Session ()
 
 Session (const std::string &_id)
 
 Session (const Session &_other)
 
virtual ~Session ()
 
Sessionoperator= (const Session &_other)
 
void setId (const std::string &_id)
 
const std::string & id (void) const
 
void setUserName (const std::string &_name)
 
const std::string & userName (void) const
 
 Session (const std::string &_ID, const std::string &_userName, const std::string &_projectName, const std::string &_collectionName, const std::string &_type)
 Constructor.
 
virtual ~Session ()
 
std::string id (void) const
 Will return the sessions ID.
 
std::string userName (void) const
 Will return the user name.
 
std::string projectName (void) const
 Will return the project name.
 
std::string collectionName (void) const
 WIll return the collection name.
 
std::string type (void) const
 Will return the type.
 
size_t serviceCount () const
 Will return the count of the services registered in this session.
 
void addRequestedService (const std::string &_serviceName, const std::string &_serviceType)
 Will add the provided service information to the requested list This list is used to identify if all the requested services have been registered.
 
void removeRequestedService (const std::string &_serviceName, const std::string &_serviceType)
 
const std::vector< std::pair< std::string, std::string > > & requestedServices (void) const
 Returns the vector containing all still requested services.
 
void addDebugPortInUse (ot::port_t _port)
 Adds the proided port number to the debug port list Debug ports will be freed when the session is closing.
 
ServiceregisterService (const std::string &_serviceIP, const std::string &_serviceName, const std::string &_serviceType, ot::serviceID_t _serviceID)
 Will store the provided service information and return the ID for the new service.
 
ServiceregisterService (Service *_service)
 Will store the provided service as service in this session.
 
void removeService (ot::serviceID_t _serviceID, bool _notifyOthers=false)
 Will remove the service with the specified ID from this session.
 
ServicegetService (ot::serviceID_t _serviceID)
 Will return the service with the specified ID.
 
ServicegetServiceFromURL (const std::string &_serviceURL)
 Will return the service with the specified URL.
 
std::list< Service * > getServicesByName (const std::string &_serviceName)
 Will return all services with the given name in this session.
 
std::string getServiceListJSON (void)
 Will return a JSON string containing all services in this session.
 
std::string infoToJSON (void) const
 Will return a JSON string representing the main information about this session.
 
void addServiceListToDocument (ot::JsonDocument &_doc)
 Will add all services to the provided document.
 
void servicesInformation (ot::JsonArray &servicesInfo, ot::JsonAllocator &allocator) const
 Will return a list of JSON objects containing information about each service.
 
void broadcastMessage (Service *_sender, const std::string &_message, bool _async=false)
 Will send a broadcast message to all services of this session.
 
void broadcastAction (Service *_sender, const std::string &_command, bool _async=false)
 Will send a broadcast message to all services of this session.
 
void broadcast (Service *_sender, const ot::JsonDocument &_message, bool _shutdown, bool _async=false)
 Will broadcast the provided message to all services in this session.
 
void shutdown (Service *_sender)
 Will shutdown the session.
 
void serviceFailure (Service *_failedService)
 
std::list< std::string > toolBarTabOrder (void)
 
void setCredentialsUsername (const std::string &username)
 
void setCredentialsPassword (const std::string &password)
 
void setUserCollection (const std::string &collection)
 
void setDatabaseUsername (const std::string &username)
 
void setDatabasePassword (const std::string &password)
 
std::string getCredentialsUsername (void)
 
std::string getCredentialsPassword (void)
 
std::string getUserCollection (void)
 
std::string getType (void)
 
std::string getDatabaseUsername (void)
 
std::string getDatabasePassword (void)
 
ot::serviceID_t generateNextServiceId (void)
 

Constructor & Destructor Documentation

◆ Session() [1/4]

Session::Session ( )

◆ Session() [2/4]

Session::Session ( const std::string & _id)

◆ Session() [3/4]

Session::Session ( const Session & _other)

◆ ~Session() [1/2]

Session::~Session ( )
virtual

◆ Session() [4/4]

Session::Session ( const std::string & _ID,
const std::string & _userName,
const std::string & _projectName,
const std::string & _collectionName,
const std::string & _type )

Constructor.

Parameters
_idThe ID of the session
_nameThe name of the session

◆ ~Session() [2/2]

virtual Session::~Session ( )
virtual

Member Function Documentation

◆ addDebugPortInUse()

void Session::addDebugPortInUse ( ot::port_t _port)

Adds the proided port number to the debug port list Debug ports will be freed when the session is closing.

◆ addRequestedService()

void Session::addRequestedService ( const std::string & _serviceName,
const std::string & _serviceType )

Will add the provided service information to the requested list This list is used to identify if all the requested services have been registered.

◆ addServiceListToDocument()

void Session::addServiceListToDocument ( ot::JsonDocument & _doc)

Will add all services to the provided document.

◆ broadcast()

void Session::broadcast ( Service * _sender,
const ot::JsonDocument & _message,
bool _shutdown,
bool _async = false )

Will broadcast the provided message to all services in this session.

Parameters
_senderThe sender of this message
_messageThe message
_asyncIf true the massage(s) will be send from a worker thread

◆ broadcastAction()

void Session::broadcastAction ( Service * _sender,
const std::string & _command,
bool _async = false )

Will send a broadcast message to all services of this session.

Parameters
_senderThe sender of this message
_commandThe command to send
_asyncIf true the massage(s) will be send from a worker thread

◆ broadcastMessage()

void Session::broadcastMessage ( Service * _sender,
const std::string & _message,
bool _async = false )

Will send a broadcast message to all services of this session.

Parameters
_senderThe sender of this message
_messageThe message text
_asyncIf true the massage(s) will be send from a worker thread

◆ collectionName()

std::string Session::collectionName ( void ) const
inline

WIll return the collection name.

◆ generateNextServiceId()

ot::serviceID_t Session::generateNextServiceId ( void )

◆ getCredentialsPassword()

std::string Session::getCredentialsPassword ( void )
inline

◆ getCredentialsUsername()

std::string Session::getCredentialsUsername ( void )
inline

◆ getDatabasePassword()

std::string Session::getDatabasePassword ( void )
inline

◆ getDatabaseUsername()

std::string Session::getDatabaseUsername ( void )
inline

◆ getService()

Service * Session::getService ( ot::serviceID_t _serviceID)

Will return the service with the specified ID.

Parameters
_serviceIPThe ID of the service

◆ getServiceFromURL()

Service * Session::getServiceFromURL ( const std::string & _serviceURL)

Will return the service with the specified URL.

Parameters
_serviceURLThe URL of the service

◆ getServiceListJSON()

std::string Session::getServiceListJSON ( void )

Will return a JSON string containing all services in this session.

◆ getServicesByName()

std::list< Service * > Session::getServicesByName ( const std::string & _serviceName)

Will return all services with the given name in this session.

◆ getType()

std::string Session::getType ( void )
inline

◆ getUserCollection()

std::string Session::getUserCollection ( void )
inline

◆ id() [1/2]

const std::string & Session::id ( void ) const
inline

◆ id() [2/2]

std::string Session::id ( void ) const
inline

Will return the sessions ID.

◆ infoToJSON()

std::string Session::infoToJSON ( void ) const

Will return a JSON string representing the main information about this session.

◆ operator=()

Session & Session::operator= ( const Session & _other)

◆ projectName()

std::string Session::projectName ( void ) const
inline

Will return the project name.

◆ registerService() [1/2]

Service * Session::registerService ( const std::string & _serviceIP,
const std::string & _serviceName,
const std::string & _serviceType,
ot::serviceID_t _serviceID )

Will store the provided service information and return the ID for the new service.

Parameters
_serviceIPThe IP of the new service
_serviceNameThe name of the service
_serviceTypeThe type of the service

◆ registerService() [2/2]

Service * Session::registerService ( Service * _service)

Will store the provided service as service in this session.

Parameters
_serviceThe service to store

◆ removeRequestedService()

void Session::removeRequestedService ( const std::string & _serviceName,
const std::string & _serviceType )

◆ removeService()

void Session::removeService ( ot::serviceID_t _serviceID,
bool _notifyOthers = false )

Will remove the service with the specified ID from this session.

Parameters
_serviceIDThe ID of the service to remove
_notifyOthersIf true, a broadcast message will be send that the service is shutting down

◆ requestedServices()

const std::vector< std::pair< std::string, std::string > > & Session::requestedServices ( void ) const
inline

Returns the vector containing all still requested services.

◆ serviceCount()

size_t Session::serviceCount ( ) const
inline

Will return the count of the services registered in this session.

◆ serviceFailure()

void Session::serviceFailure ( Service * _failedService)

◆ servicesInformation()

void Session::servicesInformation ( ot::JsonArray & servicesInfo,
ot::JsonAllocator & allocator ) const

Will return a list of JSON objects containing information about each service.

◆ setCredentialsPassword()

void Session::setCredentialsPassword ( const std::string & password)
inline

◆ setCredentialsUsername()

void Session::setCredentialsUsername ( const std::string & username)
inline

◆ setDatabasePassword()

void Session::setDatabasePassword ( const std::string & password)
inline

◆ setDatabaseUsername()

void Session::setDatabaseUsername ( const std::string & username)
inline

◆ setId()

void Session::setId ( const std::string & _id)
inline

◆ setUserCollection()

void Session::setUserCollection ( const std::string & collection)
inline

◆ setUserName()

void Session::setUserName ( const std::string & _name)
inline

◆ shutdown()

void Session::shutdown ( Service * _sender)

Will shutdown the session.

◆ toolBarTabOrder()

std::list< std::string > Session::toolBarTabOrder ( void )

◆ type()

std::string Session::type ( void ) const
inline

Will return the type.

◆ userName() [1/2]

const std::string & Session::userName ( void ) const
inline

◆ userName() [2/2]

std::string Session::userName ( void ) const
inline

Will return the user name.


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