Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
binary_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_CLIENT_WRAPPER_INCLUDE_FLUTTER_BINARY_MESSENGER_H_
6#define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_BINARY_MESSENGER_H_
7
8#include <cstdint>
9#include <functional>
10#include <string>
11
12namespace flutter {
13
14// A binary message reply callback.
15//
16// Used for submitting a binary reply back to a Flutter message sender.
17typedef std::function<void(const uint8_t* reply, size_t reply_size)>
19
20// A message handler callback.
21//
22// Used for receiving messages from Flutter and providing an asynchronous reply.
23typedef std::function<
24 void(const uint8_t* message, size_t message_size, BinaryReply reply)>
26
27// A protocol for a class that handles communication of binary data on named
28// channels to and from the Flutter engine.
30 public:
31 virtual ~BinaryMessenger() = default;
32
33 // Sends a binary message to the Flutter engine on the specified channel.
34 //
35 // If |reply| is provided, it will be called back with the response from the
36 // engine.
37 virtual void Send(const std::string& channel,
38 const uint8_t* message,
39 size_t message_size,
40 BinaryReply reply = nullptr) const = 0;
41
42 // Registers a message handler for incoming binary messages from the Flutter
43 // side on the specified channel.
44 //
45 // Replaces any existing handler. Provide a null handler to unregister the
46 // existing handler.
47 virtual void SetMessageHandler(const std::string& channel,
49};
50
51} // namespace flutter
52
53#endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_BINARY_MESSENGER_H_
virtual ~BinaryMessenger()=default
virtual void Send(const std::string &channel, const uint8_t *message, size_t message_size, BinaryReply reply=nullptr) const =0
virtual void SetMessageHandler(const std::string &channel, BinaryMessageHandler handler)=0
const char * message
const gchar * channel
const gchar FlBinaryMessengerMessageHandler handler
std::function< void(const uint8_t *message, size_t message_size, BinaryReply reply)> BinaryMessageHandler
std::function< void(const uint8_t *reply, size_t reply_size)> BinaryReply