From 30fc50144a7702dba56adb6329d36fce1db6e682 Mon Sep 17 00:00:00 2001 From: Francisco Magdaleno Date: Wed, 4 Sep 2019 10:24:04 -0700 Subject: [PATCH 1/3] Add missing InvokeMethod with a reply for glfw --- .../client_wrapper/include/flutter/method_channel.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h b/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h index e1f164076aebb..19a773ca71ebf 100644 --- a/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h +++ b/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h @@ -51,8 +51,15 @@ class MethodChannel { messenger_->Send(name_, message->data(), message->size()); } - // TODO: Add support for a version of InvokeMethod expecting a reply once - // https://github.com/flutter/flutter/issues/18852 is fixed. + // Sends a message to the Flutter engine on this channel expecting a reply. + void InvokeMethod(const std::string& method, + std::unique_ptr arguments, + flutter::BinaryReply reply) { + MethodCall method_call(method, std::move(arguments)); + std::unique_ptr> 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 // received on this channel. From baa15d71a7687cb7bccfcfa70691f09698e6ca8a Mon Sep 17 00:00:00 2001 From: Francisco Magdaleno Arceo Date: Wed, 4 Sep 2019 11:05:55 -0700 Subject: [PATCH 2/3] Add to macos --- .../darwin/common/framework/Headers/FlutterChannels.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/shell/platform/darwin/common/framework/Headers/FlutterChannels.h b/shell/platform/darwin/common/framework/Headers/FlutterChannels.h index 83c9e989762e4..b0a81e9e7de25 100644 --- a/shell/platform/darwin/common/framework/Headers/FlutterChannels.h +++ b/shell/platform/darwin/common/framework/Headers/FlutterChannels.h @@ -234,11 +234,7 @@ FLUTTER_EXPORT */ - (void)invokeMethod:(NSString*)method arguments:(id _Nullable)arguments - result:(FlutterResult _Nullable)callback - // TODO: Add macOS support for replies once - // https://github.com/flutter/flutter/issues/18852 is fixed. - API_UNAVAILABLE(macos); - + result:(FlutterResult _Nullable)callback; /** * Registers a handler for method calls from the Flutter side. * From afe34a4bdbb681634aa9c3b97870f5425bfb83cb Mon Sep 17 00:00:00 2001 From: Francisco Magdaleno Date: Wed, 4 Sep 2019 13:59:21 -0700 Subject: [PATCH 3/3] Refactor call --- .../cpp/client_wrapper/include/flutter/method_channel.h | 2 +- shell/platform/common/cpp/client_wrapper/plugin_registrar.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h b/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h index 19a773ca71ebf..4baa083cca117 100644 --- a/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h +++ b/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h @@ -48,7 +48,7 @@ class MethodChannel { MethodCall method_call(method, std::move(arguments)); std::unique_ptr> message = codec_->EncodeMethodCall(method_call); - messenger_->Send(name_, message->data(), message->size()); + messenger_->Send(name_, message->data(), message->size(), nullptr); } // Sends a message to the Flutter engine on this channel expecting a reply. diff --git a/shell/platform/common/cpp/client_wrapper/plugin_registrar.cc b/shell/platform/common/cpp/client_wrapper/plugin_registrar.cc index cf28181ed4410..7ca7c3de73b1c 100644 --- a/shell/platform/common/cpp/client_wrapper/plugin_registrar.cc +++ b/shell/platform/common/cpp/client_wrapper/plugin_registrar.cc @@ -98,8 +98,8 @@ void BinaryMessengerImpl::Send(const std::string& channel, const size_t message_size, BinaryReply reply) const { if (reply == nullptr) { - std::cerr << "Calling BinaryMessengerImpl::Send expecting a reply, but the " - "callback is null.\n"; + FlutterDesktopMessengerSend(messenger_, channel.c_str(), message, + message_size); return; } struct Captures {