pw_rpc: Classes for client & bidirectional streaming
- Implement RawServerReaderWriter and derived classes. Mostly implement
NanopbServerReaderWriter.
- Fill out MethodTraits for client/bidirectional streaming.
- Update NanopbMethodSerde argument order to match style used elsewhere
and Google style.
- Rework MethodImplTester to reduce duplication and test new features.
Change-Id: Iaf98e925d012867bd25cb4787ab5fae52ad71f54
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/51526
Reviewed-by: Alexei Frolov <frolv@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_rpc/responder.cc b/pw_rpc/responder.cc
index 6f4b78c..7761b3a 100644
--- a/pw_rpc/responder.cc
+++ b/pw_rpc/responder.cc
@@ -79,11 +79,16 @@
uint32_t Responder::method_id() const { return call_.method().id(); }
-Status Responder::CloseAndSendResponse(Status status) {
+Status Responder::CloseAndSendResponse(std::span<const std::byte> response,
+ Status status) {
if (!open()) {
return Status::FailedPrecondition();
}
+ // Send a packet indicating that the RPC has terminated.
+ Status packet_status =
+ call_.channel().Send(ResponsePacket(call_, response, status));
+
// If the Responder implementer or user forgets to release an acquired buffer
// before finishing, release it here.
if (!response_.empty()) {
@@ -92,8 +97,7 @@
Close();
- // Send a packet indicating that the RPC has terminated.
- return call_.channel().Send(ResponsePacket(call_, {}, status));
+ return packet_status;
}
std::span<std::byte> Responder::AcquirePayloadBuffer() {