Use InTransaction() for events

This commit is contained in:
flamingcow
2019-05-09 23:37:00 -07:00
parent edfafa001f
commit 8fb810c548
2 changed files with 11 additions and 10 deletions

Submodule firecgi updated: 8bd0813161...b5b0cbd599

View File

@@ -6,15 +6,16 @@ Stream::Stream(firecgi::Request* request)
: request_(request) {}
bool Stream::WriteEvent(const std::string& data, uint64_t id, const std::string& type) {
if (id) {
request_->WriteBody("id: ", std::to_string(id), "\n");
}
if (!type.empty()) {
request_->WriteBody("event: ", type, "\n");
}
request_->WriteBody("data: ", data, "\n");
return request_->Flush();
return request_->InTransaction<bool>([=]() {
if (id) {
request_->WriteBody("id: ", std::to_string(id), "\n");
}
if (!type.empty()) {
request_->WriteBody("event: ", type, "\n");
}
request_->WriteBody("data: ", data, "\n\n");
return request_->Flush();
});
}
bool Stream::End() {