| 12 | |
| 13 | template<Request C> |
| 14 | auto SyncRequest(const typename C::Params& params, uint32_t commandToken, DuplexPipe& pipe, std::optional<uint32_t> timeoutMs = {}) |
| 15 | -> as::awaitable<typename C::Response> |
| 16 | { |
| 17 | const PacketHeader reqHeader{ |
| 18 | .identifier = C::Identifier, |
| 19 | .commandToken = commandToken, |
| 20 | .packetType = PacketType::ActionRequest, |
| 21 | .headerVersion = 1, |
| 22 | .actionVersion = C::Version, |
| 23 | }; |
| 24 | co_await pipe.WritePacket(reqHeader, params, timeoutMs); |
| 25 | const auto resHeader = co_await pipe.ReadPacketConsumeHeader<PacketHeader>(timeoutMs); |
| 26 | if (resHeader.transportStatus != TransportStatus::Success) { |
| 27 | // consume the empty payload to leave the pipe stream in a clean state |
| 28 | pipe.ConsumePacketPayload<EmptyPayload>(); |
| 29 | if (resHeader.executionStatus) { |
| 30 | const auto code = (PM_STATUS)resHeader.executionStatus; |
| 31 | pmlog_error("Execution error response to SyncRequest").code(code).diag(); |
| 32 | throw util::Except<ActionExecutionError>((PM_STATUS)resHeader.executionStatus); |
| 33 | } |
| 34 | else { |
| 35 | pmlog_error("Execution error response to SyncRequest").diag().raise<util::Exception>(); |
| 36 | } |
| 37 | } |
| 38 | co_return pipe.ConsumePacketPayload<typename C::Response>(); |
| 39 | } |
| 40 | |
| 41 | template<Event C> |
| 42 | auto AsyncEmit(const typename C::Params& params, uint32_t commandToken, DuplexPipe& pipe, std::optional<uint32_t> timeoutMs = {}) |
nothing calls this directly
no test coverage detected