Flutter Engine
fl_binary_messenger.h File Reference
#include <gio/gio.h>
#include <glib-object.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

GQuark fl_binary_messenger_codec_error_quark (void) G_GNUC_CONST
 
 G_DECLARE_INTERFACE (FlBinaryMessenger, fl_binary_messenger, FL, BINARY_MESSENGER, GObject) 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)
 

Variables

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

Macro Definition Documentation

◆ FL_BINARY_MESSENGER_ERROR

#define FL_BINARY_MESSENGER_ERROR   fl_binary_messenger_codec_error_quark()

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

Errors for #FlBinaryMessenger objects to set on failures.

Definition at line 24 of file fl_binary_messenger.h.

Referenced by send_response().

Enumeration Type Documentation

◆ FlBinaryMessengerError

Enumerator
FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED 

Definition at line 26 of file fl_binary_messenger.h.

Function Documentation

◆ fl_binary_messenger_codec_error_quark()

GQuark fl_binary_messenger_codec_error_quark ( void  )

◆ 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: : an #FlBinaryMessenger. : channel to send to. : (allow-none): message buffer to send or NULL for an empty message. : (allow-none): a #GCancellable or NULL. : (scope async): a #GAsyncReadyCallback to call when the request is satisfied. : (closure): user data to pass to .

Asynchronously sends a platform message.

Definition at line 359 of file fl_binary_messenger.cc.

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(), and TEST().

365  {
366  g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
367  g_return_if_fail(channel != nullptr);
368 
369  FL_BINARY_MESSENGER_GET_IFACE(self)->send_on_channel(
370  self, channel, message, cancellable, callback, user_data);
371 }
void * user_data
FlKeyEvent FlKeyResponderAsyncCallback callback

◆ 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: : an #FlBinaryMessenger.

Returns
: a #GAsyncResult. : (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 373 of file fl_binary_messenger.cc.

References FALSE.

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

376  {
377  g_return_val_if_fail(FL_IS_BINARY_MESSENGER(self), FALSE);
378 
379  return FL_BINARY_MESSENGER_GET_IFACE(self)->send_on_channel_finish(
380  self, result, error);
381 }
const uint8_t uint32_t uint32_t GError ** error
GAsyncResult * result
return FALSE

◆ 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: : an #FlBinaryMessenger. : handle that was provided in a FlBinaryMessengerMessageHandler. : (allow-none): response to send or NULL for an empty response. : (allow-none): #GError location to store the error occurring, or NULL to ignore.

Responds to a platform message.

Returns: TRUE on success.

Definition at line 346 of file fl_binary_messenger.cc.

References FALSE.

Referenced by cancel_exception_response_cb(), fl_basic_message_channel_respond(), fl_method_channel_respond(), listen_exception_response_cb(), message_cb(), method_call_error_response_cb(), method_call_not_implemented_response_cb(), method_call_success_response_cb(), mock_message_cb(), response_cb(), and send_events_events_cb().

350  {
351  g_return_val_if_fail(FL_IS_BINARY_MESSENGER(self), FALSE);
352  g_return_val_if_fail(FL_IS_BINARY_MESSENGER_RESPONSE_HANDLE(response_handle),
353  FALSE);
354 
355  return FL_BINARY_MESSENGER_GET_IFACE(self)->send_response(
356  self, response_handle, response, error);
357 }
const uint8_t uint32_t uint32_t GError ** error
return FALSE

◆ 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: : an #FlBinaryMessenger. : channel to listen on. : (allow-none): function to call when a message is received on this channel or NULL to disable a handler : (closure): user data to pass to . : (allow-none): a function which gets called to free , 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 if you want to detect this.

Definition at line 333 of file fl_binary_messenger.cc.

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

338  {
339  g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
340  g_return_if_fail(channel != nullptr);
341 
342  FL_BINARY_MESSENGER_GET_IFACE(self)->set_message_handler_on_channel(
343  self, channel, handler, user_data, destroy_notify);
344 }
void * user_data

◆ G_DECLARE_INTERFACE()

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

Variable Documentation

◆ BINARY_MESSENGER_RESPONSE_HANDLE

BINARY_MESSENGER_RESPONSE_HANDLE

Definition at line 39 of file fl_binary_messenger.h.

◆ FL

FL

Definition at line 39 of file fl_binary_messenger.h.

◆ fl_binary_messenger_response_handle

fl_binary_messenger_response_handle

Definition at line 39 of file fl_binary_messenger.h.

◆ FlBinaryMessengerMessageHandler

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

FlBinaryMessengerMessageHandler: : an #FlBinaryMessenger. : channel message received on. : message content received from Dart. : a handle to respond to the message with. : (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 and release that once it has been responded to. Failing to respond before the last reference to is dropped is a programming error.

Definition at line 59 of file fl_binary_messenger.h.

Referenced by G_DECLARE_FINAL_TYPE().