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

@@ -19,11 +19,10 @@ void Stream::OnClose(const std::function<void()>& callback) {
on_close_ = callback;
}
bool Stream::WriteEvent(const std::string& data, uint64_t id, const std::string& type) {
{
std::lock_guard l(mu_);
index_->Freshen(this);
}
bool Stream::WriteEvent(const std::string_view& data, uint64_t id, const std::string& type) {
std::lock_guard l(mu_);
index_->Freshen(this);
return request_->InTransaction<bool>([=]() {
if (id) {
@@ -37,6 +36,13 @@ bool Stream::WriteEvent(const std::string& data, uint64_t id, const std::string&
});
}
bool Stream::WriteRaw(const std::string_view& data) {
std::lock_guard l(mu_);
request_->WriteBody(data);
return request_->Flush();
}
bool Stream::End() {
return request_->End();
}