Add queue buffers & simulation support to web proxy

This makes a couple of major changes:
-Directly uses EPoll class for managing Seasocks events.
-Adds buffers of queues to web proxy Subscribers so that we can
 transfering data losslessly in log replay.
-Modifies the flatbuffer used for the RTC communications so that
 the webpage can specify whether it wants every message or subsampled
 messages.
-Adds an option to LogReader to let us run past the end of the logfile.

Note that these changes do mean that, for log replay, the web proxy will
load the *entire* logfile into memory. Future changes can optimize this
to, e.g., only load the required channels into memory.

Change-Id: I74e7608c30baa8b36e05c4ab50e12a54bf75aa4c
diff --git a/aos/network/web_proxy_main.cc b/aos/network/web_proxy_main.cc
index 78528ea..ddab5dc 100644
--- a/aos/network/web_proxy_main.cc
+++ b/aos/network/web_proxy_main.cc
@@ -11,6 +11,7 @@
 
 DEFINE_string(config, "./config.json", "File path of aos configuration");
 DEFINE_string(data_dir, "www", "Directory to serve data files from");
+DEFINE_int32(buffer_size, 0, "-1 if infinite, in # of messages / channel.");
 
 int main(int argc, char **argv) {
   aos::InitGoogle(&argc, &argv);
@@ -22,14 +23,8 @@
 
   aos::ShmEventLoop event_loop(&config.message());
 
-  seasocks::Server server(std::shared_ptr<seasocks::Logger>(
-      new aos::seasocks::SeasocksLogger(seasocks::Logger::Level::Info)));
+  aos::web_proxy::WebProxy web_proxy(&event_loop, FLAGS_buffer_size);
+  web_proxy.SetDataPath(FLAGS_data_dir.c_str());
 
-  auto websocket_handler =
-      std::make_shared<aos::web_proxy::WebsocketHandler>(&server, &event_loop);
-  server.addWebSocketHandler("/ws", websocket_handler);
-
-  std::thread data_thread{[&event_loop]() { event_loop.Run(); }};
-
-  server.serve(FLAGS_data_dir.c_str(), 8080);
+  event_loop.Run();
 }