Working clock stream. Propagate up write errors
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <gflags/gflags.h>
|
||||
#include <glog/logging.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "sse.h"
|
||||
|
||||
@@ -10,6 +11,15 @@ int main(int argc, char *argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
SSEServer server(FLAGS_port, [](std::unique_ptr<SSEStream> stream) {
|
||||
while (true) {
|
||||
timeval tv;
|
||||
PCHECK(gettimeofday(&tv, nullptr) == 0);
|
||||
uint64_t time_ms = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
if (!stream->WriteEvent(std::to_string(time_ms), 0, "time")) {
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
});
|
||||
server.Serve();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user