Working test server
This commit is contained in:
parent
a0aa6fb0d8
commit
c89c36c49a
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
Debug
|
||||
Release
|
||||
*~
|
||||
*.o
|
||||
*.o.d
|
BIN
Debug/HTTPServer
BIN
Debug/HTTPServer
Binary file not shown.
BIN
Debug/main.cpp.o
BIN
Debug/main.cpp.o
Binary file not shown.
@ -5,12 +5,11 @@ Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \
|
||||
../ServerCore/IPAddress.h ../ServerCore/SessionFilter.h \
|
||||
../ServerCore/Command.h ../ServerCore/ConsoleServer.h \
|
||||
../ServerCore/TCPServerSocket.h ../ServerCore/Service.h \
|
||||
../ServerCore/CommandList.h ../ServerCore/EPoll.h HTTPServer.h \
|
||||
../ServerCore/TCPServerSocket.h ../ServerCore/Session.h \
|
||||
../ServerCore/CommandList.h ../ServerCore/EPoll.h \
|
||||
../ServerCore/Exception.h ../ServerCore/File.h ../ServerCore/Log.h \
|
||||
../ServerCore/IPAddress.h HTTPService.h ../ServerCore/Service.h _GET.h \
|
||||
../ServerCore/Command.h ../ServerCore/Header.h ../ServerCore/Response.h \
|
||||
_POST.h ../ServerCore/Exception.h ../ServerCore/File.h \
|
||||
../ServerCore/Log.h
|
||||
../ServerCore/Command.h ../ServerCore/Session.h ../ServerCore/Header.h \
|
||||
../ServerCore/Response.h _POST.h
|
||||
|
||||
../ServerCore/includes:
|
||||
|
||||
@ -48,11 +47,11 @@ Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \
|
||||
|
||||
../ServerCore/EPoll.h:
|
||||
|
||||
HTTPServer.h:
|
||||
../ServerCore/Exception.h:
|
||||
|
||||
../ServerCore/TCPServerSocket.h:
|
||||
../ServerCore/File.h:
|
||||
|
||||
../ServerCore/Session.h:
|
||||
../ServerCore/Log.h:
|
||||
|
||||
../ServerCore/IPAddress.h:
|
||||
|
||||
@ -64,14 +63,10 @@ _GET.h:
|
||||
|
||||
../ServerCore/Command.h:
|
||||
|
||||
../ServerCore/Session.h:
|
||||
|
||||
../ServerCore/Header.h:
|
||||
|
||||
../ServerCore/Response.h:
|
||||
|
||||
_POST.h:
|
||||
|
||||
../ServerCore/Exception.h:
|
||||
|
||||
../ServerCore/File.h:
|
||||
|
||||
../ServerCore/Log.h:
|
||||
|
27
HTTPServer.h
27
HTTPServer.h
@ -1,27 +0,0 @@
|
||||
#ifndef __HTTPServer_h__
|
||||
#define __HTTPServer_h__
|
||||
|
||||
#include "includes"
|
||||
#include "EPoll.h"
|
||||
#include "TCPServerSocket.h"
|
||||
#include "Session.h"
|
||||
#include "IPAddress.h"
|
||||
#include "HTTPService.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class HTTPServer : public core::TCPServerSocket {
|
||||
|
||||
public:
|
||||
HTTPServer(core::EPoll &ePoll, core::IPAddress address) : core::TCPServerSocket(ePoll, address) {}
|
||||
|
||||
protected:
|
||||
core::Service * getService() override {
|
||||
return new HTTPService(*this);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -2,25 +2,25 @@
|
||||
## Auto Generated makefile by CodeLite IDE
|
||||
## any manual changes will be erased
|
||||
##
|
||||
## Release
|
||||
## Debug
|
||||
ProjectName :=HTTPServer
|
||||
ConfigurationName :=Release
|
||||
WorkspacePath :=/home/barant/barant
|
||||
ProjectPath :=/home/barant/barant/HTTPServer
|
||||
IntermediateDirectory :=./Release
|
||||
ConfigurationName :=Debug
|
||||
WorkspacePath :=/home/barant/Development/BMA/server_core
|
||||
ProjectPath :=/home/barant/Development/BMA/server_core/HTTPServer
|
||||
IntermediateDirectory :=./Debug
|
||||
OutDir := $(IntermediateDirectory)
|
||||
CurrentFileName :=
|
||||
CurrentFilePath :=
|
||||
CurrentFileFullPath :=
|
||||
User :=
|
||||
Date :=03/03/19
|
||||
User :=Brad Arant
|
||||
Date :=12/03/19
|
||||
CodeLitePath :=/home/barant/.codelite
|
||||
LinkerName :=/usr/bin/x86_64-linux-gnu-g++
|
||||
SharedObjectLinkerName :=/usr/bin/x86_64-linux-gnu-g++ -shared -fPIC
|
||||
LinkerName :=g++
|
||||
SharedObjectLinkerName :=g++ -shared -fPIC
|
||||
ObjectSuffix :=.o
|
||||
DependSuffix :=.o.d
|
||||
PreprocessSuffix :=.i
|
||||
DebugSwitch :=-g
|
||||
PreprocessSuffix :=.o.i
|
||||
DebugSwitch :=-gstab
|
||||
IncludeSwitch :=-I
|
||||
LibrarySwitch :=-l
|
||||
OutputSwitch :=-o
|
||||
@ -28,7 +28,7 @@ LibraryPathSwitch :=-L
|
||||
PreprocessorSwitch :=-D
|
||||
SourceSwitch :=-c
|
||||
OutputFile :=$(IntermediateDirectory)/$(ProjectName)
|
||||
Preprocessors :=$(PreprocessorSwitch)NDEBUG
|
||||
Preprocessors :=
|
||||
ObjectSwitch :=-o
|
||||
ArchiveOutputSwitch :=
|
||||
PreprocessOnlySwitch :=-E
|
||||
@ -36,24 +36,24 @@ ObjectsFileList :="HTTPServer.txt"
|
||||
PCHCompileFlags :=
|
||||
MakeDirCommand :=mkdir -p
|
||||
LinkOptions :=
|
||||
IncludePath := $(IncludeSwitch). $(IncludeSwitch). $(IncludeSwitch)../ServerCore
|
||||
IncludePath := $(IncludeSwitch). $(IncludeSwitch). $(IncludeSwitch)../ServerCore/
|
||||
IncludePCH :=
|
||||
RcIncludePath :=
|
||||
Libs := $(LibrarySwitch)ServerCore $(LibrarySwitch)pthread
|
||||
ArLibs := "ServerCore" "pthread"
|
||||
LibPath := $(LibraryPathSwitch). $(LibraryPathSwitch)../ServerCore/Debug
|
||||
LibPath := $(LibraryPathSwitch). $(LibraryPathSwitch)../ServerCore/Debug/
|
||||
|
||||
##
|
||||
## Common variables
|
||||
## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables
|
||||
##
|
||||
AR := /usr/bin/x86_64-linux-gnu-ar rcu
|
||||
CXX := /usr/bin/x86_64-linux-gnu-g++
|
||||
CC := /usr/bin/x86_64-linux-gnu-gcc
|
||||
CXXFLAGS := -O2 -Wall $(Preprocessors)
|
||||
CFLAGS := -O2 -Wall $(Preprocessors)
|
||||
AR := ar rcus
|
||||
CXX := g++
|
||||
CC := gcc
|
||||
CXXFLAGS := -g -O0 -Wall $(Preprocessors)
|
||||
CFLAGS := -g -O0 -Wall $(Preprocessors)
|
||||
ASFLAGS :=
|
||||
AS := /usr/bin/x86_64-linux-gnu-as
|
||||
AS := as
|
||||
|
||||
|
||||
##
|
||||
@ -79,11 +79,11 @@ $(OutputFile): $(IntermediateDirectory)/.d $(Objects)
|
||||
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
|
||||
|
||||
MakeIntermediateDirs:
|
||||
@test -d ./Release || $(MakeDirCommand) ./Release
|
||||
@test -d ./Debug || $(MakeDirCommand) ./Debug
|
||||
|
||||
|
||||
$(IntermediateDirectory)/.d:
|
||||
@test -d ./Release || $(MakeDirCommand) ./Release
|
||||
@test -d ./Debug || $(MakeDirCommand) ./Debug
|
||||
|
||||
PreBuild:
|
||||
|
||||
@ -92,7 +92,7 @@ PreBuild:
|
||||
## Objects
|
||||
##
|
||||
$(IntermediateDirectory)/main.cpp$(ObjectSuffix): main.cpp $(IntermediateDirectory)/main.cpp$(DependSuffix)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/barant/HTTPServer/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/HTTPServer/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(IntermediateDirectory)/main.cpp$(DependSuffix): main.cpp
|
||||
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/main.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/main.cpp$(DependSuffix) -MM main.cpp
|
||||
|
||||
@ -105,6 +105,6 @@ $(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp
|
||||
## Clean
|
||||
##
|
||||
clean:
|
||||
$(RM) -r ./Release/
|
||||
$(RM) -r ./Debug/
|
||||
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
<Description/>
|
||||
<Dependencies/>
|
||||
<VirtualDirectory Name="src">
|
||||
<File Name="HTTPServer.h"/>
|
||||
<File Name="HTTPService.h"/>
|
||||
<File Name="_GET.h"/>
|
||||
<File Name="_POST.h"/>
|
||||
@ -109,4 +108,6 @@
|
||||
</Completion>
|
||||
</Configuration>
|
||||
</Settings>
|
||||
<Dependencies Name="Debug"/>
|
||||
<Dependencies Name="Release"/>
|
||||
</CodeLite_Project>
|
||||
|
@ -1 +1 @@
|
||||
./Release/main.cpp.o
|
||||
./Debug/main.cpp.o
|
||||
|
@ -2,18 +2,15 @@
|
||||
#define __HTTPService_h__
|
||||
|
||||
#include "Service.h"
|
||||
//#include "HTTPServer.h"
|
||||
#include "_GET.h"
|
||||
#include "_POST.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class HTTPServer;
|
||||
|
||||
class HTTPService : public core::Service {
|
||||
|
||||
public:
|
||||
HTTPService(HTTPServer &server) : core::Service((core::TCPServerSocket &)server) {
|
||||
HTTPService() {
|
||||
commands.add(get, "GET ");
|
||||
commands.add(post, "POST ");
|
||||
}
|
||||
|
14
main.cpp
14
main.cpp
@ -1,11 +1,11 @@
|
||||
#include "includes"
|
||||
#include "EPoll.h"
|
||||
#include "ConsoleServer.h"
|
||||
#include "HTTPServer.h"
|
||||
#include "Exception.h"
|
||||
#include "File.h"
|
||||
#include "Log.h"
|
||||
#include "IPAddress.h"
|
||||
#include "HTTPService.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
@ -18,12 +18,14 @@ int main(int argc, char **argv) {
|
||||
|
||||
core::EPoll ePoll;
|
||||
|
||||
http::HTTPServer http(ePoll, core::IPAddress(ipAddress, 8090));
|
||||
http::HTTPService httpService;
|
||||
core::TCPServerSocket http(ePoll, httpService, core::IPAddress(ipAddress, 8090));
|
||||
|
||||
core::ConsoleServer console(ePoll, core::IPAddress(ipAddress, 1027));
|
||||
console.service->commands.add(ePoll);
|
||||
console.service->commands.add(http);
|
||||
console.service->commands.add(console);
|
||||
core::Service consoleService;
|
||||
core::ConsoleServer console(ePoll, consoleService, core::IPAddress(ipAddress, 1027));
|
||||
consoleService.commands.add(ePoll);
|
||||
consoleService.commands.add(http);
|
||||
consoleService.commands.add(console);
|
||||
ePoll.start(4, 1000);
|
||||
|
||||
while(true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user