| Flutter macOS Embedder |

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

`#include <incoming_message_dispatcher.h>`

## Public Member Functions
| IncomingMessageDispatcher (FlutterDesktopMessengerRef messenger)
virtual | ~IncomingMessageDispatcher ()
| IncomingMessageDispatcher (IncomingMessageDispatcher const &)=delete
IncomingMessageDispatcher & | operator= (IncomingMessageDispatcher const &)=delete
void | HandleMessage (const FlutterDesktopMessage &message, const std::function< void(void)> &input_block_cb=[] {}, const std::function< void(void)> &input_unblock_cb=[] {})
void | SetMessageCallback (const std::string &channel, FlutterDesktopMessageCallback callback, void *user_data)
void | EnableInputBlockingForChannel (const std::string &channel)

## Detailed Description

Definition at line 20 of file incoming_message_dispatcher.h.

## Constructor & Destructor Documentation

## ◆ IncomingMessageDispatcher() [1/2]

flutter::IncomingMessageDispatcher::IncomingMessageDispatcher | ( | FlutterDesktopMessengerRef | messenger | ) |
| explicit

Definition at line 9 of file incoming_message_dispatcher.cc.

11 : messenger_(messenger) {}

## ◆ ~IncomingMessageDispatcher()

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

## ◆ IncomingMessageDispatcher() [2/2]

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

## Member Function Documentation

## ◆ EnableInputBlockingForChannel()

void flutter::IncomingMessageDispatcher::EnableInputBlockingForChannel | ( | const std::string & | channel | ) |

Definition at line 54 of file incoming_message_dispatcher.cc.

55 {
56 input_blocking_channels_.insert(channel);
57 }

## ◆ HandleMessage()

void flutter::IncomingMessageDispatcher::HandleMessage | ( | const FlutterDesktopMessage & | message,
|  | const std::function< void(void)> & | input_block_cb = `[] {}`,
|  | const std::function< void(void)> & | input_unblock_cb = `[] {}`
| ) |  |

Note
  Procedure doesn't copy all closures.

Definition at line 16 of file incoming_message_dispatcher.cc.

19 {
20 std::string channel(message.channel);
21
22 auto callback_iterator = callbacks_.find(channel);
23 // Find the handler for the channel; if there isn't one, report the failure.
24 if (callback_iterator == callbacks_.end()) {
25 FlutterDesktopMessengerSendResponse(messenger_, message.response_handle,
26 nullptr, 0);
27 return;
28 }
29 auto& callback_info = callback_iterator->second;
30 const FlutterDesktopMessageCallback& message_callback = callback_info.first;
31
32 // Process the call, handling input blocking if requested.
33 bool block_input = input_blocking_channels_.count(channel) > 0;
34 if (block_input) {
35 input_block_cb();
36 }
37 message_callback(messenger_, &message, callback_info.second);
38 if (block_input) {
39 input_unblock_cb();
40 }
41 }
FlutterDesktopMessengerSendResponse
FLUTTER_EXPORT void FlutterDesktopMessengerSendResponse(FlutterDesktopMessengerRef messenger, const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
FlutterDesktopMessageCallback
void(* FlutterDesktopMessageCallback)(FlutterDesktopMessengerRef, const FlutterDesktopMessage *, void *)
Definition: flutter_messenger.h:49
FlutterDesktopMessage::channel
const char * channel
Definition: flutter_messenger.h:35
FlutterDesktopMessage::response_handle
const FlutterDesktopMessageResponseHandle * response_handle
Definition: flutter_messenger.h:42

References FlutterDesktopMessage::channel, FlutterDesktopMessengerSendResponse(), and FlutterDesktopMessage::response_handle.

## ◆ operator=()

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

## ◆ SetMessageCallback()

void flutter::IncomingMessageDispatcher::SetMessageCallback | ( | const std::string & | channel,
|  | FlutterDesktopMessageCallback | callback,
|  | void * | user_data
| ) |  |

Definition at line 43 of file incoming_message_dispatcher.cc.

46 {
47 if (!callback) {
48 callbacks_.erase(channel);
49 return;
50 }
51 callbacks_[channel] = std::make_pair(callback, user_data);
52 }
user_data
void * user_data
Definition: texture_registrar_unittests.cc:27

References user_data.

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

- shell/platform/common/incoming_message_dispatcher.h
- shell/platform/common/incoming_message_dispatcher.cc