| Flutter macOS Embedder |

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
13 #include "include/flutter/binary_messenger.h"
14
15 namespace flutter {
16
17 // Wrapper around a FlutterDesktopMessengerRef that implements the
18 // BinaryMessenger API.
19 class BinaryMessengerImpl : public BinaryMessenger {
20 public:
21 explicit BinaryMessengerImpl(FlutterDesktopMessengerRef core_messenger);
22
23 virtual ~BinaryMessengerImpl();
24
25 // Prevent copying.
26 BinaryMessengerImpl(BinaryMessengerImpl const&) = delete;
27 BinaryMessengerImpl& operator=(BinaryMessengerImpl const&) = delete;
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_
flutter::BinaryMessengerImpl::BinaryMessengerImpl
BinaryMessengerImpl(FlutterDesktopMessengerRef core_messenger)
Definition: core_implementations.cc:81
flutter_messenger.h
binary_messenger.h
flutter::BinaryMessengerImpl::~BinaryMessengerImpl
virtual ~BinaryMessengerImpl()
flutter::BinaryMessengerImpl
Definition: binary_messenger_impl.h:19
flutter::BinaryMessenger
Definition: binary_messenger.h:28
flutter::BinaryReply
std::function< void(const uint8_t *reply, size_t reply_size)> BinaryReply
Definition: binary_messenger.h:17
flutter
Definition: AccessibilityBridgeMac.h:16
flutter::BinaryMessengerImpl::SetMessageHandler
void SetMessageHandler(const std::string &channel, BinaryMessageHandler handler) override
Definition: core_implementations.cc:116
FlutterDesktopMessengerRef
struct FlutterDesktopMessenger * FlutterDesktopMessengerRef
Definition: flutter_messenger.h:19
flutter::BinaryMessageHandler
std::function< void(const uint8_t *message, size_t message_size, BinaryReply reply)> BinaryMessageHandler
Definition: binary_messenger.h:24
flutter::BinaryMessengerImpl::operator=
BinaryMessengerImpl & operator=(BinaryMessengerImpl const &)=delete
flutter::BinaryMessengerImpl::Send
void Send(const std::string &channel, const uint8_t *message, size_t message_size, BinaryReply reply) const override
Definition: core_implementations.cc:87