From 8479dfe6a203210c9ff154421be66919528e52b7 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Sat, 16 Feb 2019 13:08:24 -0800 Subject: [PATCH] Fogotten objects. --- Service.cpp | 21 ++++++++++++++++++ Service.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ TLSService.cpp | 12 ++++++++++ TLSService.h | 21 ++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 Service.cpp create mode 100644 Service.h create mode 100644 TLSService.cpp create mode 100644 TLSService.h diff --git a/Service.cpp b/Service.cpp new file mode 100644 index 0000000..b1d19a7 --- /dev/null +++ b/Service.cpp @@ -0,0 +1,21 @@ +#include "Service.h" +#include "TCPServerSocket.h" +#include "Exception.h" + +namespace core { + + Service::Service(TCPServerSocket &server) : server(server) {} + + void Service::removeFromSessionList(Session *session) { + std::vector::iterator cursor; + for(cursor = sessions.begin(); cursor < sessions.end(); ++cursor) + if(*cursor == session) + sessions.erase(cursor); + } + + void Service::sessionErrorHandler(std::string errorString, Session *session) { + throw Exception(errorString); + } + +} + diff --git a/Service.h b/Service.h new file mode 100644 index 0000000..ae3eaf4 --- /dev/null +++ b/Service.h @@ -0,0 +1,60 @@ +#ifndef __Service_h__ +#define __Service_h__ + +#include "Object.h" +#include "CommandList.h" + +namespace core { + + class TCPServerSocket; + + /// + /// Service + /// + /// The Service object is instantiated as a single object upon construction + /// of the parent TCPServerSocket and is provided as a parameter whenever + /// a new Session object is created. It provides server level services to + /// Command handlers. + /// + + class Service : public Object { + + public: + + /// + /// Use this constructor to create a new Service object. + /// + /// @param server A reference to the parent server creating the object. + /// + + Service(TCPServerSocket &server); + + void removeFromSessionList(Session *session); + + virtual void sessionErrorHandler(std::string errorString, Session *session); + + /// + /// The list of sessions that are currently open and being maintained by this object. + /// + + std::vector sessions; + + /// + /// The server that is associated to this Service object. This provides access to the + /// server values and methods through the Service object which behaves as an interface. + /// + + TCPServerSocket &server; + + /// + /// The commands object is a CommandList and is used to store Command objects to be + /// parsed and run as data comes into the session. + /// + + CommandList commands; + + }; + +} + +#endif diff --git a/TLSService.cpp b/TLSService.cpp new file mode 100644 index 0000000..a943782 --- /dev/null +++ b/TLSService.cpp @@ -0,0 +1,12 @@ +#include "TLSService.h" + +namespace core { + + TLSService::TLSService(TLSServerSocket &server) : Service(server) { + + } + +} + + + \ No newline at end of file diff --git a/TLSService.h b/TLSService.h new file mode 100644 index 0000000..3254450 --- /dev/null +++ b/TLSService.h @@ -0,0 +1,21 @@ +#ifndef __TLSService_h__ +#define __TLSService_h__ + +#include "includes" +#include "Service.h" +#include "TLSServerSocket.h" + +namespace core { + + class TLSService : public Service { + + public: + TLSService(TLSServerSocket &server); + SSL_CTX *ctx; + + + }; + +} + +#endif