diff --git a/Debug/main.cpp.o b/Debug/main.cpp.o index 04f4bb1..c7eb7ab 100644 Binary files a/Debug/main.cpp.o and b/Debug/main.cpp.o differ diff --git a/Debug/main.cpp.o.d b/Debug/main.cpp.o.d index 487d2a0..91f8551 100644 --- a/Debug/main.cpp.o.d +++ b/Debug/main.cpp.o.d @@ -2,24 +2,23 @@ Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \ ../CoreUtils/Log.h ../CoreUtils/includes ../CoreUtils/File.h \ ../ServerCore/Object.h ../ServerCore/includes ../CoreUtils/LogListener.h \ ../ServerCore/Socket.h ../ServerCore/Object.h ../ServerCore/Thread.h \ - ../ServerCore/Session.h ../ServerCore/TCPSocket.h \ + ../ServerCore/TCPSession.h ../ServerCore/TCPSocket.h \ ../ServerCore/IPAddress.h ../ServerCore/SessionFilter.h \ - ../ServerCore/Command.h ../ServerCore/ConsoleService.h \ - ../ServerCore/Service.h ../ServerCore/CommandList.h \ - ../ServerCore/ConsoleSession.h ../ServerCore/TerminalSession.h \ - ../ServerCore/TCPServerSocket.h ../ServerCore/IPAddressList.h \ + ../ServerCore/Command.h ../ServerCore/ConsoleServer.h \ + ../ServerCore/TCPServer.h ../ServerCore/IPAddressList.h \ + ../ServerCore/CommandList.h ../ServerCore/EPoll.h \ ../CoreUtils/Exception.h ../CoreUtils/File.h ../ServerCore/IPAddress.h \ - HTTPService.h ../ServerCore/Service.h HTTPSessions.h HTTPRequest.h \ + HTTPServer.h HTTPService.h HTTPSessions.h HTTPRequest.h \ ../CoreUtils/PString.h ../CoreUtils/IMFMessage.h ../CoreUtils/PString.h \ ../CoreUtils/IMFHeader.h ../CoreUtils/IMFRequest.h \ ../CoreUtils/IMFBody.h ../CoreUtils/IMFRequest.h \ ../CoreUtils/IMFResponse.h ../CoreUtils/IMFMessage.h \ - ../ServerCore/Command.h ../ServerCore/Session.h HTTPPageList.h __index.h \ - HTTPPage.h HTTPSession.h ../JET/Variables.h __script.h __editview.h \ - __style.h __setupadmin.h __favicon_ico.h __welcome.h \ + ../ServerCore/Command.h ../ServerCore/TCPSession.h HTTPPageList.h \ + __index.h HTTPPage.h HTTPSession.h ../JET/Variables.h __script.h \ + __editview.h __style.h __setupadmin.h __favicon_ico.h __welcome.h \ ../BMAMySQL/BMAMySQL.h __mainmenu.h __newview.h __configure.h \ __viewlist.h ../CoreUtils/Directory.h ../CoreUtils/DirectoryEntry.h \ - HTTPHandler.h + HTTPHandler.h ../ServerCore/TCPServer.h ../ServerCore/includes: @@ -43,7 +42,7 @@ Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \ ../ServerCore/Thread.h: -../ServerCore/Session.h: +../ServerCore/TCPSession.h: ../ServerCore/TCPSocket.h: @@ -53,19 +52,15 @@ Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \ ../ServerCore/Command.h: -../ServerCore/ConsoleService.h: +../ServerCore/ConsoleServer.h: -../ServerCore/Service.h: +../ServerCore/TCPServer.h: + +../ServerCore/IPAddressList.h: ../ServerCore/CommandList.h: -../ServerCore/ConsoleSession.h: - -../ServerCore/TerminalSession.h: - -../ServerCore/TCPServerSocket.h: - -../ServerCore/IPAddressList.h: +../ServerCore/EPoll.h: ../CoreUtils/Exception.h: @@ -73,9 +68,9 @@ Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \ ../ServerCore/IPAddress.h: -HTTPService.h: +HTTPServer.h: -../ServerCore/Service.h: +HTTPService.h: HTTPSessions.h: @@ -101,7 +96,7 @@ HTTPRequest.h: ../ServerCore/Command.h: -../ServerCore/Session.h: +../ServerCore/TCPSession.h: HTTPPageList.h: @@ -140,3 +135,5 @@ __viewlist.h: ../CoreUtils/DirectoryEntry.h: HTTPHandler.h: + +../ServerCore/TCPServer.h: diff --git a/HTTPHandler.cpp b/HTTPHandler.cpp index 33415e7..1ff8a03 100644 --- a/HTTPHandler.cpp +++ b/HTTPHandler.cpp @@ -1,6 +1,6 @@ #include "HTTPHandler.h" #include "HTTPSession.h" -#include "HTTPService.h" +#include "HTTPServer.h" #include "HTTPRequest.h" #include "PString.h" #include "IMFFormData.h" @@ -8,16 +8,16 @@ namespace http { - int HTTPHandler::processCommand(std::string request, core::Session *session, std::stringstream &data) { + int HTTPHandler::processCommand(std::string request, core::TCPSession *session, std::stringstream &data) { coreutils::PString request1(request); HTTPRequest httpRequest(request1); - HTTPSession *httpSession = ((HTTPService &)session->service).httpSessions.findSessionByHeader(httpRequest); + HTTPSession *httpSession = static_cast(session->server).httpSessions.findSessionByHeader(httpRequest); std::stringstream content; - if(((HTTPService &)session->service).pageList.processRequest(httpRequest, session, httpSession, content)) { + if(static_cast(session->server).pageList.processRequest(httpRequest, session, httpSession, content)) { std::string contentType = httpRequest.getHeader("Content-Type"); if(contentType == "multipart/form-data") { coreutils::IMFFormData *formdata = (coreutils::IMFFormData *)httpRequest.getBody(); diff --git a/HTTPHandler.h b/HTTPHandler.h index a1a3c50..e521ae8 100644 --- a/HTTPHandler.h +++ b/HTTPHandler.h @@ -2,7 +2,7 @@ #define __HTTPHandler_h__ #include "Command.h" -#include "Session.h" +#include "TCPSession.h" #include "Log.h" namespace http { @@ -10,7 +10,7 @@ namespace http { class HTTPHandler : public core::Command { public: - int processCommand(std::string request, core::Session *session, std::stringstream &data) override; + int processCommand(std::string request, core::TCPSession *session, std::stringstream &data) override; }; diff --git a/HTTPPage.h b/HTTPPage.h index 372161b..0af1c0f 100644 --- a/HTTPPage.h +++ b/HTTPPage.h @@ -3,7 +3,7 @@ #include "HTTPSession.h" #include "HTTPRequest.h" -#include "Session.h" +#include "TCPSession.h" #include "Log.h" namespace http { @@ -23,7 +23,7 @@ namespace http { } virtual int processCommand(std::string request, - core::Session *session, + core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) { diff --git a/HTTPPageList.cpp b/HTTPPageList.cpp index 436b4f5..96bc4a0 100644 --- a/HTTPPageList.cpp +++ b/HTTPPageList.cpp @@ -2,7 +2,7 @@ namespace http { - bool HTTPPageList::processRequest(HTTPRequest &httpRequest, core::Session *session, HTTPSession *httpSession, std::stringstream &data) { + bool HTTPPageList::processRequest(HTTPRequest &httpRequest, core::TCPSession *session, HTTPSession *httpSession, std::stringstream &data) { httpRequest.response.setProtocol(httpRequest.request.getProtocol()); for(auto *page : pages) { if(page->check(httpRequest.request.getURI())) { diff --git a/HTTPPageList.h b/HTTPPageList.h index 1c0524f..8aaff2d 100644 --- a/HTTPPageList.h +++ b/HTTPPageList.h @@ -1,7 +1,7 @@ #ifndef __HTTPPageList_h__ #define __HTTPPageList_h__ -#include "Session.h" +#include "TCPSession.h" #include "HTTPRequest.h" #include "__index.h" #include "__script.h" @@ -34,7 +34,7 @@ namespace http { add(viewlist, "/viewlist"); } - bool processRequest(HTTPRequest &httpRequest, core::Session *session, HTTPSession *httpSession, std::stringstream &data); + bool processRequest(HTTPRequest &httpRequest, core::TCPSession *session, HTTPSession *httpSession, std::stringstream &data); void add(HTTPPage &page, std::string name = ""); diff --git a/HTTPService.h b/HTTPServer.h similarity index 51% rename from HTTPService.h rename to HTTPServer.h index 4627821..b98ffff 100644 --- a/HTTPService.h +++ b/HTTPServer.h @@ -1,31 +1,31 @@ -#ifndef __HTTPService_h__ -#define __HTTPService_h__ +#ifndef __HTTPServer_h__ +#define __HTTPServer_h__ -#include "Service.h" +#include "TCPServer.h" #include "HTTPSessions.h" #include "HTTPPageList.h" -#include "Exception.h" #include "HTTPHandler.h" namespace http { - - class HTTPService : public core::Service { - + + class HTTPServer : public core::TCPServer { + public: - HTTPService() { + HTTPServer(core::EPoll &ePoll, core::IPAddress ipAddress, HTTPSessions &httpSessions) + : TCPServer(ePoll, ipAddress), httpSessions(httpSessions) { commands.add(getHandler, "GET"); commands.add(postHandler, "POST"); - } + } - HTTPSessions httpSessions; + HTTPSessions &httpSessions; HTTPPageList pageList; private: HTTPHandler getHandler; HTTPHandler postHandler; - - }; + }; + } #endif diff --git a/HTTPServer.mk b/HTTPServer.mk index 51715dc..166b9e3 100644 --- a/HTTPServer.mk +++ b/HTTPServer.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Brad Arant -Date :=12/09/19 +Date :=18/09/19 CodeLitePath :=/home/bradarant/.codelite LinkerName :=/usr/bin/x86_64-linux-gnu-g++ SharedObjectLinkerName :=/usr/bin/x86_64-linux-gnu-g++ -shared -fPIC diff --git a/HTTPServer.project b/HTTPServer.project index 32454eb..15248d3 100644 --- a/HTTPServer.project +++ b/HTTPServer.project @@ -3,7 +3,6 @@ - @@ -27,6 +26,7 @@ + diff --git a/HTTPSessions.cpp b/HTTPSessions.cpp index 99746b7..c4e82c2 100644 --- a/HTTPSessions.cpp +++ b/HTTPSessions.cpp @@ -44,7 +44,7 @@ namespace http { return uuid_s; } - int HTTPSessions::processCommand(std::string command, core::Session *session, std::stringstream &data) { + int HTTPSessions::processCommand(std::string command, core::TCPSession *session, std::stringstream &data) { if(sessions.size() > 0) { int seq = 0; for(auto httpSession: sessions) diff --git a/HTTPSessions.h b/HTTPSessions.h index c7a49e8..7d44d50 100644 --- a/HTTPSessions.h +++ b/HTTPSessions.h @@ -3,7 +3,7 @@ #include "HTTPRequest.h" #include "Command.h" -#include "Session.h" +#include "TCPSession.h" namespace http { @@ -15,7 +15,7 @@ namespace http { HTTPSession * findSessionByHeader(HTTPRequest &httpRequest); HTTPSession * findSessionById(std::string sessionId, HTTPRequest &httpRequest); - int processCommand(std::string request, core::Session *session, std::stringstream &data); + int processCommand(std::string request, core::TCPSession *session, std::stringstream &data); private: HTTPSession * createHTTPSession(); diff --git a/__configure.h b/__configure.h index 2b8d60c..0e415ea 100644 --- a/__configure.h +++ b/__configure.h @@ -5,7 +5,7 @@ namespace http { class __configure : public HTTPPage { - int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { + int processCommand(std::string request, core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { data << "
" << std::endl; data << "

System Configuration

" << std::endl; diff --git a/__editview.h b/__editview.h index b59530b..4f0e26c 100644 --- a/__editview.h +++ b/__editview.h @@ -7,7 +7,7 @@ namespace http { class __editview : public HTTPPage { - int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { + int processCommand(std::string request, core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { data << "
" << std::endl; data << "" << std::endl; diff --git a/__favicon_ico.h b/__favicon_ico.h index bf53117..db7ccbc 100644 --- a/__favicon_ico.h +++ b/__favicon_ico.h @@ -8,7 +8,7 @@ namespace http { class __favicon_ico : public HTTPPage { int processCommand(std::string request, - core::Session *session, + core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { diff --git a/__index.h b/__index.h index 79b6224..02bad31 100644 --- a/__index.h +++ b/__index.h @@ -8,7 +8,7 @@ namespace http { class __index : public HTTPPage { - int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { + int processCommand(std::string request, core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { data << "" << std::endl; data << " " << std::endl; diff --git a/__mainmenu.h b/__mainmenu.h index 3bf47db..c1807eb 100644 --- a/__mainmenu.h +++ b/__mainmenu.h @@ -8,7 +8,7 @@ namespace http { class __mainmenu : public HTTPPage { int processCommand(std::string request, - core::Session *session, + core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { diff --git a/__newview.h b/__newview.h index 8c19263..fcd419d 100644 --- a/__newview.h +++ b/__newview.h @@ -8,7 +8,7 @@ namespace http { class __newview : public HTTPPage { int processCommand(std::string request, - core::Session *session, + core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { diff --git a/__script.h b/__script.h index 9622ad9..65ff8df 100644 --- a/__script.h +++ b/__script.h @@ -7,7 +7,7 @@ namespace http { class __script : public HTTPPage { - int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { + int processCommand(std::string request, core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { data << "function serverSend(url, type, receiver, formData, callback) {" << std::endl; data << " var server = new XMLHttpRequest();" << std::endl; diff --git a/__setupadmin.h b/__setupadmin.h index b21f541..0b72962 100644 --- a/__setupadmin.h +++ b/__setupadmin.h @@ -5,7 +5,7 @@ namespace http { class __setupadmin : public HTTPPage { - int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { + int processCommand(std::string request, core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { data << "" << std::endl; data << "

Please enter credential information" << std::endl; diff --git a/__style.h b/__style.h index 0a79a19..675f3c2 100644 --- a/__style.h +++ b/__style.h @@ -7,7 +7,7 @@ namespace http { class __style : public HTTPPage { - int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { + int processCommand(std::string request, core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { data << "body {background: #006;" << std::endl; data << " color: #fff;" << std::endl; diff --git a/__viewlist.h b/__viewlist.h index 31cbbe4..7b2096d 100644 --- a/__viewlist.h +++ b/__viewlist.h @@ -9,7 +9,7 @@ namespace http { class __viewlist : public HTTPPage { int processCommand(std::string request, - core::Session *session, + core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { diff --git a/__welcome.h b/__welcome.h index 5e6ed1d..9c4732b 100644 --- a/__welcome.h +++ b/__welcome.h @@ -9,7 +9,7 @@ namespace http { class __welcome : public HTTPPage { int processCommand(std::string request, - core::Session *session, + core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { diff --git a/main.cpp b/main.cpp index cb9769a..9131470 100644 --- a/main.cpp +++ b/main.cpp @@ -1,11 +1,11 @@ #include "includes" #include "EPoll.h" -#include "ConsoleService.h" +#include "ConsoleServer.h" #include "Exception.h" #include "File.h" #include "Log.h" #include "IPAddress.h" -#include "HTTPService.h" +#include "HTTPServer.h" int main(int argc, char **argv) { @@ -18,17 +18,17 @@ int main(int argc, char **argv) { core::EPoll ePoll; - http::HTTPService httpService; - core::TCPServerSocket http(ePoll, httpService, core::IPAddress(ipAddress, 8080)); + http::HTTPSessions httpSessions; + http::HTTPServer http(ePoll, core::IPAddress(ipAddress, 8080), httpSessions); +// http::HTTPSServer http(ePoll, core::IPAddress(ipAddress, 8143)); - core::ConsoleService consoleService; - core::TCPServerSocket console(ePoll, consoleService, core::IPAddress(ipAddress, 1027)); + core::ConsoleServer console(ePoll, core::IPAddress(ipAddress, 1027)); - consoleService.commands.add(ePoll, "threads"); - consoleService.commands.add(httpService.httpSessions, "sessions"); - consoleService.commands.add(console, "consoles"); - consoleService.commands.add(consoleService.commands, "help"); - ePoll.start(16, 1000); + console.commands.add(ePoll, "threads"); + console.commands.add(httpSessions, "sessions"); + console.commands.add(console, "consoles"); + console.commands.add(console.commands, "help"); + ePoll.start(2, 1000); while(true) sleep(300);