diff --git a/Makefile b/Makefile index c9c8a03..e427bc6 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,16 @@ -example_simple: example_simple.o fastcgi.o fastcgi_conn.o fastcgi_request.o fastcgi_parse.o stream_buffer.o buffer.o - clang++ -std=gnu++2a -o example_simple example_simple.o fastcgi.o fastcgi_conn.o fastcgi_request.o fastcgi_parse.o stream_buffer.o buffer.o -lgflags -lglog -lpthread +all: example_simple example_clock + +objects = sse.o fastcgi.o fastcgi_conn.o fastcgi_request.o fastcgi_parse.o stream_buffer.o buffer.o + +example_simple: example_simple.o $(objects) Makefile + clang++ -std=gnu++2a -o example_simple example_simple.o $(objects) -lgflags -lglog -lpthread + +example_clock: example_clock.o $(objects) Makefile + clang++ -std=gnu++2a -o example_clock example_clock.o $(objects) -lgflags -lglog -lpthread + +%.o: %.cc *.h Makefile + clang++ -std=gnu++2a -Wall -Werror -c -o $@ $< clean: - rm --force exmaple_simple *.o + rm --force exmaple_simple example_clock *.o -.cpp.o: - clang++ -std=gnu++2a -Wall -Werror -o $@ -c $< diff --git a/buffer.cpp b/buffer.cc similarity index 100% rename from buffer.cpp rename to buffer.cc diff --git a/example_clock b/example_clock new file mode 100755 index 0000000..c190396 Binary files /dev/null and b/example_clock differ diff --git a/example_clock.cc b/example_clock.cc new file mode 100644 index 0000000..f69adc5 --- /dev/null +++ b/example_clock.cc @@ -0,0 +1,15 @@ +#include +#include + +#include "sse.h" + +DEFINE_int32(port, 9000, "TCP port to bind"); + +int main(int argc, char *argv[]) { + google::InitGoogleLogging(argv[0]); + gflags::ParseCommandLineFlags(&argc, &argv, true); + + SSEServer server(FLAGS_port, [](std::unique_ptr stream) { + }); + server.Serve(); +} diff --git a/example_simple.cpp b/example_simple.cc similarity index 100% rename from example_simple.cpp rename to example_simple.cc diff --git a/fastcgi.cpp b/fastcgi.cc similarity index 100% rename from fastcgi.cpp rename to fastcgi.cc diff --git a/fastcgi_conn.cpp b/fastcgi_conn.cc similarity index 100% rename from fastcgi_conn.cpp rename to fastcgi_conn.cc diff --git a/fastcgi_parse.cpp b/fastcgi_parse.cc similarity index 100% rename from fastcgi_parse.cpp rename to fastcgi_parse.cc diff --git a/fastcgi_request.cpp b/fastcgi_request.cc similarity index 100% rename from fastcgi_request.cpp rename to fastcgi_request.cc diff --git a/sse.cc b/sse.cc new file mode 100644 index 0000000..8be369a --- /dev/null +++ b/sse.cc @@ -0,0 +1,8 @@ +#include "sse.h" + +SSEServer::SSEServer(int port, const std::function)>& callback) + : fastcgi_server_(port, [](std::unique_ptr request) {}) {} + +void SSEServer::Serve() { + fastcgi_server_.Serve(); +} diff --git a/sse.h b/sse.h new file mode 100644 index 0000000..7146bd9 --- /dev/null +++ b/sse.h @@ -0,0 +1,13 @@ +#pragma once + +#include "fastcgi.h" +#include "sse_stream.h" + +class SSEServer { + public: + SSEServer(int port, const std::function)>& callback); + void Serve(); + + private: + FastCGIServer fastcgi_server_; +}; diff --git a/sse_stream.h b/sse_stream.h new file mode 100644 index 0000000..11a3289 --- /dev/null +++ b/sse_stream.h @@ -0,0 +1,4 @@ +#pragma once + +class SSEStream { +}; diff --git a/stream_buffer.cpp b/stream_buffer.cc similarity index 100% rename from stream_buffer.cpp rename to stream_buffer.cc