Fogotten objects.
This commit is contained in:
parent
2cb1e3e2f2
commit
8479dfe6a2
21
Service.cpp
Normal file
21
Service.cpp
Normal file
@ -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<Session *>::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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
60
Service.h
Normal file
60
Service.h
Normal file
@ -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<Session *> 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
|
12
TLSService.cpp
Normal file
12
TLSService.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "TLSService.h"
|
||||||
|
|
||||||
|
namespace core {
|
||||||
|
|
||||||
|
TLSService::TLSService(TLSServerSocket &server) : Service(server) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
21
TLSService.h
Normal file
21
TLSService.h
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user