Flutter Linux Embedder
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
binary_messenger_impl.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_BINARY_MESSENGER_IMPL_H_
6 #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_BINARY_MESSENGER_IMPL_H_
7 
8 #include <flutter_messenger.h>
9 
10 #include <map>
11 #include <string>
12 
14 
15 namespace flutter {
16 
17 // Wrapper around a FlutterDesktopMessengerRef that implements the
18 // BinaryMessenger API.
20  public:
21  explicit BinaryMessengerImpl(FlutterDesktopMessengerRef core_messenger);
22 
24 
25  // Prevent copying.
28 
29  // |flutter::BinaryMessenger|
30  void Send(const std::string& channel,
31  const uint8_t* message,
32  size_t message_size,
33  BinaryReply reply) const override;
34 
35  // |flutter::BinaryMessenger|
36  void SetMessageHandler(const std::string& channel,
37  BinaryMessageHandler handler) override;
38 
39  private:
40  // Handle for interacting with the C API.
41  FlutterDesktopMessengerRef messenger_;
42 
43  // A map from channel names to the BinaryMessageHandler that should be called
44  // for incoming messages on that channel.
45  std::map<std::string, BinaryMessageHandler> handlers_;
46 };
47 
48 } // namespace flutter
49 
50 #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_BINARY_MESSENGER_IMPL_H_
BinaryMessengerImpl(FlutterDesktopMessengerRef core_messenger)
BinaryMessengerImpl & operator=(BinaryMessengerImpl const &)=delete
BinaryMessengerImpl(BinaryMessengerImpl const &)=delete
void SetMessageHandler(const std::string &channel, BinaryMessageHandler handler) override
void Send(const std::string &channel, const uint8_t *message, size_t message_size, BinaryReply reply) const override
struct FlutterDesktopMessenger * FlutterDesktopMessengerRef
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