Use InTransaction() for events
This commit is contained in:
2
firecgi
2
firecgi
Submodule firecgi updated: 8bd0813161...b5b0cbd599
19
stream.cc
19
stream.cc
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user