| Flutter Windows Embedder |

Classes | Typedefs | Functions
flutter_messenger.h File Reference
`#include <stdbool.h>`
`#include <stddef.h>`
`#include <stdint.h>`
`#include "flutter_export.h"`

Go to the source code of this file.

## Classes
struct | FlutterDesktopMessage

## Typedefs
typedef struct FlutterDesktopMessenger * | FlutterDesktopMessengerRef
typedef struct _FlutterPlatformMessageResponseHandle | FlutterDesktopMessageResponseHandle
typedef void(* | FlutterDesktopBinaryReply) (const uint8_t *data, size_t data_size, void *user_data)
typedef void(* | FlutterDesktopMessageCallback) (FlutterDesktopMessengerRef, const FlutterDesktopMessage *, void *)

## Functions
FLUTTER_EXPORT bool | FlutterDesktopMessengerSend (FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size)
FLUTTER_EXPORT bool | FlutterDesktopMessengerSendWithReply (FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
FLUTTER_EXPORT void | FlutterDesktopMessengerSendResponse (FlutterDesktopMessengerRef messenger, const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
FLUTTER_EXPORT void | FlutterDesktopMessengerSetCallback (FlutterDesktopMessengerRef messenger, const char *channel, FlutterDesktopMessageCallback callback, void *user_data)
FLUTTER_EXPORT FlutterDesktopMessengerRef | FlutterDesktopMessengerAddRef (FlutterDesktopMessengerRef messenger)
FLUTTER_EXPORT void | FlutterDesktopMessengerRelease (FlutterDesktopMessengerRef messenger)
FLUTTER_EXPORT bool | FlutterDesktopMessengerIsAvailable (FlutterDesktopMessengerRef messenger)
FLUTTER_EXPORT FlutterDesktopMessengerRef | FlutterDesktopMessengerLock (FlutterDesktopMessengerRef messenger)
FLUTTER_EXPORT void | FlutterDesktopMessengerUnlock (FlutterDesktopMessengerRef messenger)

## Typedef Documentation

## ◆ FlutterDesktopBinaryReply

typedef void(* FlutterDesktopBinaryReply) (const uint8_t *data, size_t data_size, void *user_data)

Definition at line 26 of file flutter_messenger.h.

## ◆ FlutterDesktopMessageCallback

typedef void(* FlutterDesktopMessageCallback) (FlutterDesktopMessengerRef, const FlutterDesktopMessage *, void *)

Definition at line 49 of file flutter_messenger.h.

## ◆ FlutterDesktopMessageResponseHandle

typedef struct _FlutterPlatformMessageResponseHandle FlutterDesktopMessageResponseHandle

Definition at line 22 of file flutter_messenger.h.

## ◆ FlutterDesktopMessengerRef

typedef struct FlutterDesktopMessenger* FlutterDesktopMessengerRef

Definition at line 19 of file flutter_messenger.h.

## Function Documentation

## ◆ FlutterDesktopMessengerAddRef()

FLUTTER_EXPORT FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 349 of file flutter_windows.cc.

350 {
351 return flutter::FlutterDesktopMessenger::FromRef(messenger)
352 ->AddRef()
353 ->ToRef();
354 }

References flutter::FlutterDesktopMessenger::AddRef(), flutter::FlutterDesktopMessenger::FromRef(), and flutter::FlutterDesktopMessenger::ToRef().

## ◆ FlutterDesktopMessengerIsAvailable()

FLUTTER_EXPORT bool FlutterDesktopMessengerIsAvailable | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 360 of file flutter_windows.cc.

360 {
361 return flutter::FlutterDesktopMessenger::FromRef(messenger)->GetEngine() !=
362 nullptr;
363 }

References flutter::FlutterDesktopMessenger::FromRef(), and flutter::FlutterDesktopMessenger::GetEngine().

Referenced by FlutterDesktopMessengerSendResponse(), FlutterDesktopMessengerSendWithReply(), and FlutterDesktopMessengerSetCallback().

## ◆ FlutterDesktopMessengerLock()

FLUTTER_EXPORT FlutterDesktopMessengerRef FlutterDesktopMessengerLock | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 365 of file flutter_windows.cc.

366 {
367 flutter::FlutterDesktopMessenger::FromRef(messenger)->GetMutex().lock();
368 return messenger;
369 }

References flutter::FlutterDesktopMessenger::FromRef(), and flutter::FlutterDesktopMessenger::GetMutex().

## ◆ FlutterDesktopMessengerRelease()

FLUTTER_EXPORT void FlutterDesktopMessengerRelease | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 356 of file flutter_windows.cc.

356 {
357 flutter::FlutterDesktopMessenger::FromRef(messenger)->Release();
358 }

References flutter::FlutterDesktopMessenger::FromRef(), and flutter::FlutterDesktopMessenger::Release().

## ◆ FlutterDesktopMessengerSend()

FLUTTER_EXPORT bool FlutterDesktopMessengerSend | ( | FlutterDesktopMessengerRef | messenger,
|  | const char * | channel,
|  | const uint8_t * | message,
|  | const size_t | message_size
| ) |  |

Definition at line 315 of file flutter_windows.cc.

318 {
319 return FlutterDesktopMessengerSendWithReply(messenger, channel, message,
320 message_size, nullptr, nullptr);
321 }

References FlutterDesktopMessengerSendWithReply(), and message.

Referenced by flutter::BinaryMessengerImpl::Send().

## ◆ FlutterDesktopMessengerSendResponse()

FLUTTER_EXPORT void FlutterDesktopMessengerSendResponse | ( | FlutterDesktopMessengerRef | messenger,
|  | const FlutterDesktopMessageResponseHandle * | handle,
|  | const uint8_t * | data,
|  | size_t | data_length
| ) |  |

Definition at line 323 of file flutter_windows.cc.

327 {
328 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
329 << "Messenger must reference a running engine to send a response";
330
331 flutter::FlutterDesktopMessenger::FromRef(messenger)
332 ->GetEngine()
333 ->SendPlatformMessageResponse(handle, data, data_length);
334 }

References FlutterDesktopMessengerIsAvailable(), flutter::FlutterDesktopMessenger::FromRef(), flutter::FlutterDesktopMessenger::GetEngine(), and flutter::FlutterWindowsEngine::SendPlatformMessageResponse().

Referenced by flutter::IncomingMessageDispatcher::HandleMessage().

## ◆ 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
| ) |  |

Definition at line 301 of file flutter_windows.cc.

306 {
307 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
308 << "Messenger must reference a running engine to send a message";
309
310 return flutter::FlutterDesktopMessenger::FromRef(messenger)
311 ->GetEngine()
312 ->SendPlatformMessage(channel, message, message_size, reply, user_data);
313 }

References FlutterDesktopMessengerIsAvailable(), flutter::FlutterDesktopMessenger::FromRef(), flutter::FlutterDesktopMessenger::GetEngine(), message, flutter::FlutterWindowsEngine::SendPlatformMessage(), and user_data.

Referenced by FlutterDesktopMessengerSend(), and flutter::BinaryMessengerImpl::Send().

## ◆ FlutterDesktopMessengerSetCallback()

FLUTTER_EXPORT void FlutterDesktopMessengerSetCallback | ( | FlutterDesktopMessengerRef | messenger,
|  | const char * | channel,
|  | FlutterDesktopMessageCallback | callback,
|  | void * | user_data
| ) |  |

Definition at line 336 of file flutter_windows.cc.

339 {
340 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
341 << "Messenger must reference a running engine to set a callback";
342
343 flutter::FlutterDesktopMessenger::FromRef(messenger)
344 ->GetEngine()
345 ->message_dispatcher()
346 ->SetMessageCallback(channel, callback, user_data);
347 }

References callback, FlutterDesktopMessengerIsAvailable(), flutter::FlutterDesktopMessenger::FromRef(), flutter::FlutterDesktopMessenger::GetEngine(), flutter::FlutterWindowsEngine::message_dispatcher(), flutter::IncomingMessageDispatcher::SetMessageCallback(), and user_data.

Referenced by flutter::BinaryMessengerImpl::SetMessageHandler().

## ◆ FlutterDesktopMessengerUnlock()

FLUTTER_EXPORT void FlutterDesktopMessengerUnlock | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 371 of file flutter_windows.cc.

371 {
372 flutter::FlutterDesktopMessenger::FromRef(messenger)->GetMutex().unlock();
373 }

References flutter::FlutterDesktopMessenger::FromRef(), and flutter::FlutterDesktopMessenger::GetMutex().

user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:49
flutter::FlutterDesktopMessenger::ToRef
FlutterDesktopMessengerRef ToRef()
Convert to FlutterDesktopMessengerRef.
Definition: flutter_desktop_messenger.h:28
flutter::FlutterWindowsEngine::SendPlatformMessage
bool SendPlatformMessage(const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
Definition: flutter_windows_engine.cc:528
flutter::FlutterDesktopMessenger::GetMutex
std::mutex & GetMutex()
Definition: flutter_desktop_messenger.h:70
flutter::FlutterDesktopMessenger::Release
void Release()
Definition: flutter_desktop_messenger.h:59
flutter::FlutterWindowsEngine::SendPlatformMessageResponse
void SendPlatformMessageResponse(const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
Definition: flutter_windows_engine.cc:562
flutter::FlutterDesktopMessenger::GetEngine
flutter::FlutterWindowsEngine * GetEngine() const
Getter for the engine field.
Definition: flutter_desktop_messenger.h:38
flutter::IncomingMessageDispatcher::SetMessageCallback
void SetMessageCallback(const std::string &channel, FlutterDesktopMessageCallback callback, void *user_data)
Definition: incoming_message_dispatcher.cc:43
flutter::FlutterWindowsEngine::message_dispatcher
IncomingMessageDispatcher * message_dispatcher()
Definition: flutter_windows_engine.h:132
flutter::FlutterDesktopMessenger::AddRef
FlutterDesktopMessenger * AddRef()
Definition: flutter_desktop_messenger.h:50
FlutterDesktopMessengerIsAvailable
bool FlutterDesktopMessengerIsAvailable(FlutterDesktopMessengerRef messenger)
Definition: flutter_windows.cc:360
message
Win32Message message
Definition: keyboard_unittests.cc:137
flutter::FlutterDesktopMessenger::FromRef
static FlutterDesktopMessenger * FromRef(FlutterDesktopMessengerRef ref)
Convert from FlutterDesktopMessengerRef.
Definition: flutter_desktop_messenger.h:33
FlutterDesktopMessengerSendWithReply
bool FlutterDesktopMessengerSendWithReply(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
Definition: flutter_windows.cc:301
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:48