| Flutter iOS Embedder |

Public Member Functions | List of all members
flutter::BinaryMessengerImpl Class Reference

`#include <binary_messenger_impl.h>`

Inheritance diagram for flutter::BinaryMessengerImpl:

## Public Member Functions
| BinaryMessengerImpl (FlutterDesktopMessengerRef core_messenger)
virtual | ~BinaryMessengerImpl ()
| BinaryMessengerImpl (BinaryMessengerImpl const &)=delete
BinaryMessengerImpl & | operator= (BinaryMessengerImpl const &)=delete
void | Send (const std::string &channel, const uint8_t *message, size_t message_size, BinaryReply reply) const override
void | SetMessageHandler (const std::string &channel, BinaryMessageHandler handler) override
Public Member Functions inherited from flutter::BinaryMessenger
virtual | ~BinaryMessenger ()=default

## Detailed Description

Definition at line 19 of file binary_messenger_impl.h.

## Constructor & Destructor Documentation

## ◆ BinaryMessengerImpl() [1/2]

flutter::BinaryMessengerImpl::BinaryMessengerImpl | ( | FlutterDesktopMessengerRef | core_messenger | ) |
| explicit

Definition at line 79 of file core_implementations.cc.

81 : messenger_(core_messenger) {}

## ◆ ~BinaryMessengerImpl()

flutter::BinaryMessengerImpl::~BinaryMessengerImpl | ( |  | ) |
| virtual default

## ◆ BinaryMessengerImpl() [2/2]

flutter::BinaryMessengerImpl::BinaryMessengerImpl | ( | BinaryMessengerImpl const & |  | ) |
| delete

## Member Function Documentation

## ◆ operator=()

BinaryMessengerImpl& flutter::BinaryMessengerImpl::operator= | ( | BinaryMessengerImpl const & |  | ) |
| delete

## ◆ Send()

void flutter::BinaryMessengerImpl::Send | ( | const std::string & | channel,
|  | const uint8_t * | message,
|  | size_t | message_size,
|  | BinaryReply | reply
| ) |  | const
| override virtual

Implements flutter::BinaryMessenger.

Definition at line 85 of file core_implementations.cc.

88 {
89 if (reply == nullptr) {
90 FlutterDesktopMessengerSend(messenger_, channel.c_str(), message,
91 message_size);
92 return;
93 }
94 struct Captures {
95 BinaryReply reply;
96 };
97 auto captures = new Captures();
98 captures->reply = reply;
99
100 auto message_reply = [](const uint8_t* data, size_t data_size,
101 void* user_data) {
102 auto captures = reinterpret_cast<Captures*>(user_data);
103 captures->reply(data, data_size);
104 delete captures;
105 };
106 bool result = FlutterDesktopMessengerSendWithReply(
107 messenger_, channel.c_str(), message, message_size, message_reply,
108 captures);
109 if (!result) {
110 delete captures;
111 }
112 }

References FlutterDesktopMessengerSend(), FlutterDesktopMessengerSendWithReply(), and user_data.

## ◆ SetMessageHandler()

void flutter::BinaryMessengerImpl::SetMessageHandler | ( | const std::string & | channel,
|  | BinaryMessageHandler | handler
| ) |  |
| override virtual

Implements flutter::BinaryMessenger.

Definition at line 114 of file core_implementations.cc.

115 {
116 if (!handler) {
117 handlers_.erase(channel);
118 FlutterDesktopMessengerSetCallback(messenger_, channel.c_str(), nullptr,
119 nullptr);
120 return;
121 }
122 // Save the handler, to keep it alive.
123 handlers_[channel] = std::move(handler);
124 BinaryMessageHandler* message_handler = &handlers_[channel];
125 // Set an adaptor callback that will invoke the handler.
126 FlutterDesktopMessengerSetCallback(messenger_, channel.c_str(),
127 ForwardToHandler, message_handler);
128 }

References FlutterDesktopMessengerSetCallback().

The documentation for this class was generated from the following files:

- shell/platform/common/client_wrapper/binary_messenger_impl.h
- shell/platform/common/client_wrapper/core_implementations.cc

FlutterDesktopMessengerSendWithReply
FLUTTER_EXPORT bool FlutterDesktopMessengerSendWithReply(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
user_data
void * user_data
Definition: texture_registrar_unittests.cc:27
FlutterDesktopMessengerSetCallback
FLUTTER_EXPORT void FlutterDesktopMessengerSetCallback(FlutterDesktopMessengerRef messenger, const char *channel, FlutterDesktopMessageCallback callback, void *user_data)
flutter::BinaryReply
std::function< void(const uint8_t *reply, size_t reply_size)> BinaryReply
Definition: binary_messenger.h:17
FlutterDesktopMessengerSend
FLUTTER_EXPORT bool FlutterDesktopMessengerSend(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size)
flutter::BinaryMessageHandler
std::function< void(const uint8_t *message, size_t message_size, BinaryReply reply)> BinaryMessageHandler
Definition: binary_messenger.h:24