Add keepalive comment messages, per spec

This commit is contained in:
flamingcow
2019-05-12 11:18:59 -07:00
parent b079f48367
commit 9162799be0
9 changed files with 140 additions and 8 deletions

View File

@@ -15,7 +15,8 @@ class Stream {
void OnClose(const std::function<void()>& callback);
bool WriteEvent(const std::string& data, uint64_t id=0, const std::string& type="");
bool WriteEvent(const std::string_view& data, uint64_t id=0, const std::string& type="");
bool WriteRaw(const std::string_view& data);
bool End();
void Close();
@@ -25,7 +26,8 @@ class Stream {
std::function<void()> on_close_;
std::mutex mu_;
// TODO: What exactly is this protecting?
std::recursive_mutex mu_;
std::chrono::steady_clock::time_point last_message_time_;
Stream* fresher_;
Stream* staler_;