Flutter Engine
flutter::IncomingMessageDispatcher Class Reference

#include <incoming_message_dispatcher.h>

Public Member Functions

 IncomingMessageDispatcher (FlutterDesktopMessengerRef messenger)
 
virtual ~IncomingMessageDispatcher ()
 
 IncomingMessageDispatcher (IncomingMessageDispatcher const &)=delete
 
IncomingMessageDispatcheroperator= (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.

References ~IncomingMessageDispatcher().

11  : messenger_(messenger) {}

◆ ~IncomingMessageDispatcher()

flutter::IncomingMessageDispatcher::~IncomingMessageDispatcher ( )
virtualdefault

◆ IncomingMessageDispatcher() [2/2]

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

Member Function Documentation

◆ EnableInputBlockingForChannel()

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

Definition at line 53 of file incoming_message_dispatcher.cc.

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

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

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

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

◆ 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 42 of file incoming_message_dispatcher.cc.

45  {
46  if (!callback) {
47  callbacks_.erase(channel);
48  return;
49  }
50  callbacks_[channel] = std::make_pair(callback, user_data);
51 }
G_BEGIN_DECLS FlValue gpointer user_data

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