Flutter Engine
fl_method_channel_private.h File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_method_channel.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_method_response.h"

Go to the source code of this file.

Functions

G_BEGIN_DECLS gboolean fl_method_channel_respond (FlMethodChannel *channel, FlBinaryMessengerResponseHandle *response_handle, FlMethodResponse *response, GError **error)
 

Function Documentation

◆ fl_method_channel_respond()

G_BEGIN_DECLS gboolean fl_method_channel_respond ( FlMethodChannel *  channel,
FlBinaryMessengerResponseHandle *  response_handle,
FlMethodResponse *  response,
GError **  error 
)

fl_method_channel_respond: : an #FlMethodChannel. : an #FlBinaryMessengerResponseHandle. : an #FlMethodResponse. : (allow-none): #GError location to store the error occurring, or NULL to ignore.

Responds to a method call.

Returns: TRUE on success.

Definition at line 215 of file fl_method_channel.cc.

References fl_binary_messenger_send_response(), fl_method_codec_encode_error_envelope(), fl_method_codec_encode_success_envelope(), fl_method_error_response_get_code(), fl_method_error_response_get_details(), fl_method_error_response_get_message(), and fl_method_success_response_get_result().

Referenced by fl_method_call_respond(), fl_method_call_respond_error(), fl_method_call_respond_not_implemented(), and fl_method_call_respond_success().

219  {
220  g_return_val_if_fail(FL_IS_METHOD_CHANNEL(self), FALSE);
221  g_return_val_if_fail(FL_IS_BINARY_MESSENGER_RESPONSE_HANDLE(response_handle),
222  FALSE);
223  g_return_val_if_fail(FL_IS_METHOD_SUCCESS_RESPONSE(response) ||
224  FL_IS_METHOD_ERROR_RESPONSE(response) ||
225  FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE(response),
226  FALSE);
227 
228  g_autoptr(GBytes) message = nullptr;
229  if (FL_IS_METHOD_SUCCESS_RESPONSE(response)) {
230  FlMethodSuccessResponse* r = FL_METHOD_SUCCESS_RESPONSE(response);
233  if (message == nullptr) {
234  return FALSE;
235  }
236  } else if (FL_IS_METHOD_ERROR_RESPONSE(response)) {
237  FlMethodErrorResponse* r = FL_METHOD_ERROR_RESPONSE(response);
239  self->codec, fl_method_error_response_get_code(r),
242  if (message == nullptr) {
243  return FALSE;
244  }
245  } else if (FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE(response)) {
246  message = nullptr;
247  } else {
248  g_assert_not_reached();
249  }
250 
251  return fl_binary_messenger_send_response(self->messenger, response_handle,
252  message, error);
253 }
FlMethodResponse GError ** error
G_MODULE_EXPORT FlValue * fl_method_success_response_get_result(FlMethodSuccessResponse *self)
G_MODULE_EXPORT const gchar * fl_method_error_response_get_message(FlMethodErrorResponse *self)
G_MODULE_EXPORT gboolean fl_binary_messenger_send_response(FlBinaryMessenger *self, FlBinaryMessengerResponseHandle *response_handle, GBytes *response, GError **error)
G_MODULE_EXPORT const gchar * fl_method_error_response_get_code(FlMethodErrorResponse *self)
GBytes * fl_method_codec_encode_error_envelope(FlMethodCodec *self, const gchar *code, const gchar *message, FlValue *details, GError **error)
GBytes * fl_method_codec_encode_success_envelope(FlMethodCodec *self, FlValue *result, GError **error)
G_MODULE_EXPORT FlValue * fl_method_error_response_get_details(FlMethodErrorResponse *self)