92 {
93 if (!handler) {
95 return;
96 }
97 const auto* codec = codec_;
98 std::string channel_name = name_;
100 const uint8_t* binary_message,
101 const size_t binary_message_size,
103
104
106 codec->DecodeMessage(binary_message, binary_message_size);
108 std::cerr << "Unable to decode message on channel " << channel_name
109 << std::endl;
110 binary_reply(nullptr, 0);
111 return;
112 }
113
114 MessageReply<T> unencoded_reply = [binary_reply,
115 codec](
const T& unencoded_response) {
116 auto binary_response = codec->EncodeMessage(unencoded_response);
117 binary_reply(binary_response->data(), binary_response->size());
118 };
119 handler(*
message, std::move(unencoded_reply));
120 };
122 }
virtual void SetMessageHandler(const std::string &channel, BinaryMessageHandler handler)=0
std::function< void(const uint8_t *message, size_t message_size, BinaryReply reply)> BinaryMessageHandler
std::function< void(const uint8_t *reply, size_t reply_size)> BinaryReply