Flutter Linux Embedder
flutter::BinaryMessengerImpl Class Reference

#include <binary_messenger_impl.h>

Inheritance diagram for flutter::BinaryMessengerImpl:
flutter::BinaryMessenger

Public Member Functions

 BinaryMessengerImpl (FlutterDesktopMessengerRef core_messenger)
 
virtual ~BinaryMessengerImpl ()
 
 BinaryMessengerImpl (BinaryMessengerImpl const &)=delete
 
BinaryMessengerImploperator= (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 81 of file core_implementations.cc.

83  : messenger_(core_messenger) {}

◆ ~BinaryMessengerImpl()

flutter::BinaryMessengerImpl::~BinaryMessengerImpl ( )
virtualdefault

◆ 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
overridevirtual

Implements flutter::BinaryMessenger.

Definition at line 87 of file core_implementations.cc.

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

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

◆ SetMessageHandler()

void flutter::BinaryMessengerImpl::SetMessageHandler ( const std::string &  channel,
BinaryMessageHandler  handler 
)
overridevirtual

Implements flutter::BinaryMessenger.

Definition at line 116 of file core_implementations.cc.

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

References FlutterDesktopMessengerSetCallback().


The documentation for this class was generated from the following files:
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
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data
Definition: fl_key_channel_responder.cc:121
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
result
GAsyncResult * result
Definition: fl_text_input_handler.cc:106
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