5#ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_CHANNEL_H_
6#define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_CHANNEL_H_
33template <
typename T = EncodableValue>
39 const std::string&
name,
41 : messenger_(messenger), name_(
name), codec_(codec) {}
54 std::unique_ptr<T> arguments,
57 std::unique_ptr<std::vector<uint8_t>>
message =
67 std::shared_ptr<MethodResult<T>> shared_result(
result.release());
68 const auto* codec = codec_;
69 std::string channel_name = name_;
70 BinaryReply reply_handler = [shared_result, codec, channel_name](
71 const uint8_t* reply,
size_t reply_size) {
72 if (reply_size == 0) {
73 shared_result->NotImplemented();
78 bool decoded = codec->DecodeAndProcessResponseEnvelope(
79 reply, reply_size, shared_result.get());
81 std::cerr <<
"Unable to decode reply to method "
82 "invocation on channel "
83 << channel_name << std::endl;
84 shared_result->NotImplemented();
89 std::move(reply_handler));
104 const auto* codec = codec_;
105 std::string channel_name = name_;
112 std::make_unique<EngineMethodResult<T>>(std::move(reply), codec);
114 codec->DecodeMethodCall(
message, message_size);
116 std::cerr <<
"Unable to construct method call from message on channel "
117 << channel_name << std::endl;
virtual void Send(const std::string &channel, const uint8_t *message, size_t message_size, BinaryReply reply=nullptr) const =0
virtual void SetMessageHandler(const std::string &channel, BinaryMessageHandler handler)=0
void SetMethodCallHandler(MethodCallHandler< T > handler) const
MethodChannel & operator=(MethodChannel const &)=delete
void Resize(int new_size)
MethodChannel(BinaryMessenger *messenger, const std::string &name, const MethodCodec< T > *codec)
void InvokeMethod(const std::string &method, std::unique_ptr< T > arguments, std::unique_ptr< MethodResult< T > > result=nullptr)
void SetWarnsOnOverflow(bool warns)
MethodChannel(MethodChannel const &)=delete
G_BEGIN_DECLS G_MODULE_EXPORT FlMethodCall * method_call
Dart_NativeFunction function
void SetChannelWarnsOnOverflow(BinaryMessenger *messenger, std::string name, bool warns)
void ResizeChannel(BinaryMessenger *messenger, std::string name, int new_size)
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
DEF_SWITCHES_START aot vmservice shared library name
std::function< void(const MethodCall< T > &call, std::unique_ptr< MethodResult< T > > result)> MethodCallHandler