5 #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_BASIC_MESSAGE_CHANNEL_H_
6 #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_BASIC_MESSAGE_CHANNEL_H_
24 void ResizeChannel(BinaryMessenger* messenger, std::string name,
int new_size);
55 template <
typename T = EncodableValue>
61 const std::string& name,
63 : messenger_(messenger), name_(name), codec_(codec) {}
72 void Send(
const T& message) {
73 std::unique_ptr<std::vector<uint8_t>> raw_message =
74 codec_->EncodeMessage(message);
75 messenger_->
Send(name_, raw_message->data(), raw_message->size());
80 std::unique_ptr<std::vector<uint8_t>> raw_message =
81 codec_->EncodeMessage(message);
82 messenger_->
Send(name_, raw_message->data(), raw_message->size(),
97 const auto* codec = codec_;
98 std::string channel_name = name_;
100 const uint8_t* binary_message,
101 const size_t binary_message_size,
105 std::unique_ptr<T> message =
106 codec->DecodeMessage(binary_message, binary_message_size);
108 std::cerr <<
"Unable to decode message on channel " << channel_name
110 binary_reply(
nullptr, 0);
115 codec](
const T& unencoded_response) {
116 auto binary_response = codec->EncodeMessage(unencoded_response);
117 binary_reply(binary_response->data(), binary_response->size());
119 handler(*message, std::move(unencoded_reply));
149 #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_BASIC_MESSAGE_CHANNEL_H_