Flutter Engine
The Flutter Engine
flutter_messenger.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_MESSENGER_H_
6#define FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_MESSENGER_H_
7
8#include <stdbool.h>
9#include <stddef.h>
10#include <stdint.h>
11
12#include "flutter_export.h"
13
14#if defined(__cplusplus)
15extern "C" {
16#endif // defined(__cplusplus)
17
18// Opaque reference to a Flutter engine messenger.
20
21// Opaque handle for tracking responses to messages.
24
25// The callback expected as a response of a binary message.
26typedef void (*FlutterDesktopBinaryReply)(const uint8_t* data,
27 size_t data_size,
28 void* user_data);
29
30// A message received from Flutter.
31typedef struct {
32 // Size of this struct as created by Flutter.
34 // The name of the channel used for this message.
35 const char* channel;
36 // The raw message data.
37 const uint8_t* message;
38 // The length of |message|.
40 // The response handle. If non-null, the receiver of this message must call
41 // FlutterDesktopSendMessageResponse exactly once with this handle.
44
45// Function pointer type for message handler callback registration.
46//
47// The user data will be whatever was passed to FlutterDesktopSetMessageHandler
48// for the channel the message is received on.
50 FlutterDesktopMessengerRef /* messenger */,
51 const FlutterDesktopMessage* /* message*/,
52 void* /* user data */);
53
54// Sends a binary message to the Flutter side on the specified channel.
57 const char* channel,
58 const uint8_t* message,
59 const size_t message_size);
60
61// Sends a binary message to the Flutter side on the specified channel.
62// The |reply| callback will be executed when a response is received.
65 const char* channel,
66 const uint8_t* message,
67 const size_t message_size,
68 const FlutterDesktopBinaryReply reply,
69 void* user_data);
70
71// Sends a reply to a FlutterDesktopMessage for the given response handle.
72//
73// Once this has been called, |handle| is invalid and must not be used again.
77 const uint8_t* data,
78 size_t data_length);
79
80// Registers a callback function for incoming binary messages from the Flutter
81// side on the specified channel.
82//
83// Replaces any existing callback. Provide a null handler to unregister the
84// existing callback.
85//
86// If |user_data| is provided, it will be passed in |callback| calls.
89 const char* channel,
91 void* user_data);
92
93// Increments the reference count for the |messenger|.
94//
95// Operation is thread-safe.
96//
97// See also: |FlutterDesktopMessengerRelease|
100
101// Decrements the reference count for the |messenger|.
102//
103// Operation is thread-safe.
104//
105// See also: |FlutterDesktopMessengerAddRef|
108
109// Returns `true` if the |FlutterDesktopMessengerRef| still references a running
110// engine.
111//
112// This check should be made inside of a |FlutterDesktopMessengerLock| and
113// before any other calls are made to the FlutterDesktopMessengerRef when using
114// it from a thread other than the platform thread.
117
118// Locks the `FlutterDesktopMessengerRef` ensuring that
119// |FlutterDesktopMessengerIsAvailable| does not change while locked.
120//
121// All calls to the FlutterDesktopMessengerRef from threads other than the
122// platform thread should happen inside of a lock.
123//
124// Operation is thread-safe.
125//
126// Returns the |messenger| value.
127//
128// See also: |FlutterDesktopMessengerUnlock|
131
132// Unlocks the `FlutterDesktopMessengerRef`.
133//
134// Operation is thread-safe.
135//
136// See also: |FlutterDesktopMessengerLock|
139
140#if defined(__cplusplus)
141} // extern "C"
142#endif
143
144#endif // FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_MESSENGER_H_
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FLUTTER_EXPORT
void(* FlutterDesktopBinaryReply)(const uint8_t *data, size_t data_size, void *user_data)
struct FlutterDesktopMessenger * FlutterDesktopMessengerRef
FLUTTER_EXPORT void FlutterDesktopMessengerSendResponse(FlutterDesktopMessengerRef messenger, const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
FLUTTER_EXPORT bool FlutterDesktopMessengerIsAvailable(FlutterDesktopMessengerRef messenger)
FLUTTER_EXPORT FlutterDesktopMessengerRef FlutterDesktopMessengerLock(FlutterDesktopMessengerRef messenger)
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 FlutterDesktopMessengerSetCallback(FlutterDesktopMessengerRef messenger, const char *channel, FlutterDesktopMessageCallback callback, void *user_data)
FLUTTER_EXPORT FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef(FlutterDesktopMessengerRef messenger)
FLUTTER_EXPORT bool FlutterDesktopMessengerSend(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size)
void(* FlutterDesktopMessageCallback)(FlutterDesktopMessengerRef, const FlutterDesktopMessage *, void *)
FLUTTER_EXPORT void FlutterDesktopMessengerRelease(FlutterDesktopMessengerRef messenger)
FLUTTER_EXPORT void FlutterDesktopMessengerUnlock(FlutterDesktopMessengerRef messenger)
Win32Message message
const uint8_t * message
const FlutterDesktopMessageResponseHandle * response_handle
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
void * user_data