Rename to .cc, fix Makefile bugs, add example_clock
This commit is contained in:
18
Makefile
18
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
|
all: example_simple example_clock
|
||||||
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
|
|
||||||
|
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:
|
clean:
|
||||||
rm --force exmaple_simple *.o
|
rm --force exmaple_simple example_clock *.o
|
||||||
|
|
||||||
.cpp.o:
|
|
||||||
clang++ -std=gnu++2a -Wall -Werror -o $@ -c $<
|
|
||||||
|
|||||||
BIN
example_clock
Executable file
BIN
example_clock
Executable file
Binary file not shown.
15
example_clock.cc
Normal file
15
example_clock.cc
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include <gflags/gflags.h>
|
||||||
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
#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<SSEStream> stream) {
|
||||||
|
});
|
||||||
|
server.Serve();
|
||||||
|
}
|
||||||
8
sse.cc
Normal file
8
sse.cc
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#include "sse.h"
|
||||||
|
|
||||||
|
SSEServer::SSEServer(int port, const std::function<void(std::unique_ptr<SSEStream>)>& callback)
|
||||||
|
: fastcgi_server_(port, [](std::unique_ptr<FastCGIRequest> request) {}) {}
|
||||||
|
|
||||||
|
void SSEServer::Serve() {
|
||||||
|
fastcgi_server_.Serve();
|
||||||
|
}
|
||||||
13
sse.h
Normal file
13
sse.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "fastcgi.h"
|
||||||
|
#include "sse_stream.h"
|
||||||
|
|
||||||
|
class SSEServer {
|
||||||
|
public:
|
||||||
|
SSEServer(int port, const std::function<void(std::unique_ptr<SSEStream>)>& callback);
|
||||||
|
void Serve();
|
||||||
|
|
||||||
|
private:
|
||||||
|
FastCGIServer fastcgi_server_;
|
||||||
|
};
|
||||||
4
sse_stream.h
Normal file
4
sse_stream.h
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class SSEStream {
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user