Flutter Linux Embedder
fl_binary_messenger.h File Reference
#include "fl_value.h"
#include <gio/gio.h>
#include <glib-object.h>
#include <gmodule.h>

Go to the source code of this file.

Classes

struct  _FlBinaryMessengerInterface
 
struct  _FlBinaryMessengerResponseHandleClass
 

Macros

#define FL_BINARY_MESSENGER_ERROR   fl_binary_messenger_codec_error_quark()
 

Enumerations

enum  FlBinaryMessengerError { FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED }
 

Functions

G_MODULE_EXPORT GQuark fl_binary_messenger_codec_error_quark (void) G_GNUC_CONST
 
G_MODULE_EXPORT G_DECLARE_INTERFACE (FlBinaryMessenger, fl_binary_messenger, FL, BINARY_MESSENGER, GObject) G_MODULE_EXPORT G_DECLARE_DERIVABLE_TYPE(FlBinaryMessengerResponseHandle
 
void fl_binary_messenger_set_message_handler_on_channel (FlBinaryMessenger *messenger, const gchar *channel, FlBinaryMessengerMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
 
gboolean fl_binary_messenger_send_response (FlBinaryMessenger *messenger, FlBinaryMessengerResponseHandle *response_handle, GBytes *response, GError **error)
 
void fl_binary_messenger_send_on_channel (FlBinaryMessenger *messenger, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
 
GBytes * fl_binary_messenger_send_on_channel_finish (FlBinaryMessenger *messenger, GAsyncResult *result, GError **error)
 
void fl_binary_messenger_resize_channel (FlBinaryMessenger *messenger, const gchar *channel, int64_t new_size)
 
void fl_binary_messenger_set_warns_on_channel_overflow (FlBinaryMessenger *messenger, const gchar *channel, bool warns)
 

Variables

G_MODULE_EXPORT GObject typedef void(* FlBinaryMessengerMessageHandler )(FlBinaryMessenger *messenger, const gchar *channel, GBytes *message, FlBinaryMessengerResponseHandle *response_handle, gpointer user_data)
 
G_MODULE_EXPORT fl_binary_messenger_response_handle
 
G_MODULE_EXPORT FL
 
G_MODULE_EXPORT BINARY_MESSENGER_RESPONSE_HANDLE
 

Macro Definition Documentation

◆ FL_BINARY_MESSENGER_ERROR

#define FL_BINARY_MESSENGER_ERROR   fl_binary_messenger_codec_error_quark()

FlBinaryMessengerError: @FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED: unable to send response, this message has already been responded to.

Errors for #FlBinaryMessenger objects to set on failures.

Definition at line 27 of file fl_binary_messenger.h.

Enumeration Type Documentation

◆ FlBinaryMessengerError

Enumerator
FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED 

Definition at line 29 of file fl_binary_messenger.h.

29  {
30  // Part of the public API, so fixing the name is a breaking change.
31  // NOLINTNEXTLINE(readability-identifier-naming)

Function Documentation

◆ fl_binary_messenger_codec_error_quark()

G_MODULE_EXPORT GQuark fl_binary_messenger_codec_error_quark ( void  )

◆ fl_binary_messenger_resize_channel()

void fl_binary_messenger_resize_channel ( FlBinaryMessenger *  messenger,
const gchar *  channel,
int64_t  new_size 
)

fl_binary_messenger_resize_channel: @binary_messenger: an #FlBinaryMessenger. @channel: channel to be resize. @new_size: the new size for the channel buffer.

Sends a message to the control channel asking to resize a channel buffer.

Definition at line 467 of file fl_binary_messenger.cc.

469  {
470  g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
471 
472  return FL_BINARY_MESSENGER_GET_IFACE(self)->resize_channel(self, channel,
473  new_size);
474 }

Referenced by TEST().

◆ fl_binary_messenger_send_on_channel()

void fl_binary_messenger_send_on_channel ( FlBinaryMessenger *  messenger,
const gchar *  channel,
GBytes *  message,
GCancellable *  cancellable,
GAsyncReadyCallback  callback,
gpointer  user_data 
)

fl_binary_messenger_send_on_channel: @binary_messenger: an #FlBinaryMessenger. @channel: channel to send to. @message: (allow-none): message buffer to send or NULL for an empty message. @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied. @user_data: (closure): user data to pass to @callback.

Asynchronously sends a platform message.

Definition at line 443 of file fl_binary_messenger.cc.

449  {
450  g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
451  g_return_if_fail(channel != nullptr);
452 
453  FL_BINARY_MESSENGER_GET_IFACE(self)->send_on_channel(
454  self, channel, message, cancellable, callback, user_data);
455 }

References callback, and user_data.

Referenced by fl_basic_message_channel_send(), fl_event_channel_send(), fl_event_channel_send_end_of_stream(), fl_event_channel_send_error(), fl_method_channel_invoke_method(), resize_channel(), send_lifecycle_state(), set_warns_on_channel_overflow(), and TEST().

◆ fl_binary_messenger_send_on_channel_finish()

GBytes* fl_binary_messenger_send_on_channel_finish ( FlBinaryMessenger *  messenger,
GAsyncResult *  result,
GError **  error 
)

fl_binary_messenger_send_on_channel_finish: @messenger: an #FlBinaryMessenger.

Returns
: a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_binary_messenger_send_on_channel().

Returns: (transfer full): message response on success or NULL on error.

Definition at line 457 of file fl_binary_messenger.cc.

460  {
461  g_return_val_if_fail(FL_IS_BINARY_MESSENGER(self), FALSE);
462 
463  return FL_BINARY_MESSENGER_GET_IFACE(self)->send_on_channel_finish(
464  self, result, error);
465 }

References error, and result.

Referenced by echo_response_cb(), failure_response_cb(), fake_response_cb(), finish_method(), fl_basic_message_channel_send_finish(), fl_method_channel_invoke_method_finish(), and nullptr_response_cb().

◆ fl_binary_messenger_send_response()

gboolean fl_binary_messenger_send_response ( FlBinaryMessenger *  messenger,
FlBinaryMessengerResponseHandle *  response_handle,
GBytes *  response,
GError **  error 
)

fl_binary_messenger_send_response: @binary_messenger: an #FlBinaryMessenger. @response_handle: handle that was provided in a FlBinaryMessengerMessageHandler. @response: (allow-none): response to send or NULL for an empty response. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Responds to a platform message. This function is thread-safe.

Returns: TRUE on success.

Definition at line 430 of file fl_binary_messenger.cc.

434  {
435  g_return_val_if_fail(FL_IS_BINARY_MESSENGER(self), FALSE);
436  g_return_val_if_fail(FL_IS_BINARY_MESSENGER_RESPONSE_HANDLE(response_handle),
437  FALSE);
438 
439  return FL_BINARY_MESSENGER_GET_IFACE(self)->send_response(
440  self, response_handle, response, error);
441 }

References error.

Referenced by cancel_exception_response_cb(), fake_message_cb(), fl_basic_message_channel_respond(), fl_method_channel_respond(), fl_test_application_activate(), listen_exception_response_cb(), message_cb(), method_call_error_response_cb(), method_call_not_implemented_response_cb(), method_call_success_response_cb(), response_cb(), response_from_thread_main(), send_events_events_cb(), and TEST().

◆ fl_binary_messenger_set_message_handler_on_channel()

void fl_binary_messenger_set_message_handler_on_channel ( FlBinaryMessenger *  messenger,
const gchar *  channel,
FlBinaryMessengerMessageHandler  handler,
gpointer  user_data,
GDestroyNotify  destroy_notify 
)

FlBinaryMessenger:

#FlBinaryMessenger is an object that allows sending and receiving of platform messages with an #FlEngine. FlBinaryMessengerResponseHandle:

#FlBinaryMessengerResponseHandle is an object used to send responses with. fl_binary_messenger_set_platform_message_handler: @binary_messenger: an #FlBinaryMessenger. @channel: channel to listen on. @handler: (allow-none): function to call when a message is received on this channel or NULL to disable a handler @user_data: (closure): user data to pass to @handler. @destroy_notify: (allow-none): a function which gets called to free @user_data, or NULL.

Sets the function called when a platform message is received on the given channel. See FlBinaryMessengerMessageHandler for details on how to respond to messages.

The handler is removed if the channel is closed or is replaced by another handler, set @destroy_notify if you want to detect this.

Definition at line 416 of file fl_binary_messenger.cc.

421  {
422  g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
423  g_return_if_fail(channel != nullptr);
424 
425  FL_BINARY_MESSENGER_GET_IFACE(self)->set_message_handler_on_channel(
426  self, channel, handler, user_data, destroy_notify);
427 }

References user_data.

Referenced by fl_basic_message_channel_dispose(), fl_basic_message_channel_new(), fl_event_channel_dispose(), fl_event_channel_new(), fl_method_channel_new(), and TEST().

◆ fl_binary_messenger_set_warns_on_channel_overflow()

void fl_binary_messenger_set_warns_on_channel_overflow ( FlBinaryMessenger *  messenger,
const gchar *  channel,
bool  warns 
)

fl_binary_messenger_set_warns_on_channel_overflow: @messenger: an #FlBinaryMessenger. @channel: channel to be allowed to overflow silently. @warns: when false, the channel is expected to overflow and warning messages will not be shown.

Sends a message to the control channel asking to allow or disallow a channel to overflow silently.

Definition at line 476 of file fl_binary_messenger.cc.

479  {
480  g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
481 
482  return FL_BINARY_MESSENGER_GET_IFACE(self)->set_warns_on_channel_overflow(
483  self, channel, warns);
484 }

Referenced by TEST().

◆ G_DECLARE_INTERFACE()

G_MODULE_EXPORT G_DECLARE_INTERFACE ( FlBinaryMessenger  ,
fl_binary_messenger  ,
FL  ,
BINARY_MESSENGER  ,
GObject   
)

Variable Documentation

◆ BINARY_MESSENGER_RESPONSE_HANDLE

G_MODULE_EXPORT BINARY_MESSENGER_RESPONSE_HANDLE

Definition at line 49 of file fl_binary_messenger.h.

◆ FL

G_MODULE_EXPORT FL

Definition at line 48 of file fl_binary_messenger.h.

◆ fl_binary_messenger_response_handle

G_MODULE_EXPORT fl_binary_messenger_response_handle

Definition at line 47 of file fl_binary_messenger.h.

◆ FlBinaryMessengerMessageHandler

G_MODULE_EXPORT GObject typedef void(* FlBinaryMessengerMessageHandler) (FlBinaryMessenger *messenger, const gchar *channel, GBytes *message, FlBinaryMessengerResponseHandle *response_handle, gpointer user_data)

FlBinaryMessengerMessageHandler: @messenger: an #FlBinaryMessenger. @channel: channel message received on. @message: message content received from Dart. @response_handle: a handle to respond to the message with. @user_data: (closure): data provided when registering this handler.

Function called when platform messages are received. Call fl_binary_messenger_send_response() to respond to this message. If the response is not occurring in this callback take a reference to @response_handle and release that once it has been responded to. Failing to respond before the last reference to @response_handle is dropped is a programming error.

Definition at line 67 of file fl_binary_messenger.h.

Referenced by G_DECLARE_FINAL_TYPE().

user_data
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data
Definition: fl_key_channel_responder.cc:121
FlBinaryMessengerError
FlBinaryMessengerError
Definition: fl_binary_messenger.h:29
result
GAsyncResult * result
Definition: fl_text_input_handler.cc:106
FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED
@ FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED
Definition: fl_binary_messenger.h:32
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
callback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Definition: fl_key_channel_responder.cc:120