未验证 提交 ef26c460 编写于 作者: F Francisco Magdaleno 提交者: GitHub

Finish plumbing message responses on method channels (#11877)

上级 48dd7b93
...@@ -48,11 +48,18 @@ class MethodChannel { ...@@ -48,11 +48,18 @@ class MethodChannel {
MethodCall<T> method_call(method, std::move(arguments)); MethodCall<T> method_call(method, std::move(arguments));
std::unique_ptr<std::vector<uint8_t>> message = std::unique_ptr<std::vector<uint8_t>> message =
codec_->EncodeMethodCall(method_call); codec_->EncodeMethodCall(method_call);
messenger_->Send(name_, message->data(), message->size()); messenger_->Send(name_, message->data(), message->size(), nullptr);
} }
// TODO: Add support for a version of InvokeMethod expecting a reply once // Sends a message to the Flutter engine on this channel expecting a reply.
// https://github.com/flutter/flutter/issues/18852 is fixed. void InvokeMethod(const std::string& method,
std::unique_ptr<T> arguments,
flutter::BinaryReply reply) {
MethodCall<T> method_call(method, std::move(arguments));
std::unique_ptr<std::vector<uint8_t>> message =
codec_->EncodeMethodCall(method_call);
messenger_->Send(name_, message->data(), message->size(), reply);
}
// Registers a handler that should be called any time a method call is // Registers a handler that should be called any time a method call is
// received on this channel. // received on this channel.
......
...@@ -98,8 +98,8 @@ void BinaryMessengerImpl::Send(const std::string& channel, ...@@ -98,8 +98,8 @@ void BinaryMessengerImpl::Send(const std::string& channel,
const size_t message_size, const size_t message_size,
BinaryReply reply) const { BinaryReply reply) const {
if (reply == nullptr) { if (reply == nullptr) {
std::cerr << "Calling BinaryMessengerImpl::Send expecting a reply, but the " FlutterDesktopMessengerSend(messenger_, channel.c_str(), message,
"callback is null.\n"; message_size);
return; return;
} }
struct Captures { struct Captures {
......
...@@ -234,11 +234,7 @@ FLUTTER_EXPORT ...@@ -234,11 +234,7 @@ FLUTTER_EXPORT
*/ */
- (void)invokeMethod:(NSString*)method - (void)invokeMethod:(NSString*)method
arguments:(id _Nullable)arguments arguments:(id _Nullable)arguments
result:(FlutterResult _Nullable)callback result:(FlutterResult _Nullable)callback;
// TODO: Add macOS support for replies once
// https://github.com/flutter/flutter/issues/18852 is fixed.
API_UNAVAILABLE(macos);
/** /**
* Registers a handler for method calls from the Flutter side. * Registers a handler for method calls from the Flutter side.
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册