| Flutter macOS Embedder |

FlutterBinaryMessengerRelay.mm
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 #import "flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.h"
6
7 #include "flutter/fml/logging.h"
8
9 FLUTTER_ASSERT_ARC
10
11 @implementation FlutterBinaryMessengerRelay
12 #pragma mark - FlutterBinaryMessenger
13
14 - (instancetype)initWithParent:(NSObject<FlutterBinaryMessenger>*)parent {
15 self = [super init];
16 if (self != nil) {
17 _parent = parent;
18 }
19 return self;
20 }
21
22 - (void)sendOnChannel:(NSString*)channel message:(NSData*)message {
23 if (self.parent) {
24 [self.parent sendOnChannel:channel message:message binaryReply:nil];
25 } else {
26 FML_LOG(WARNING) << "Communicating on a dead channel.";
27 }
28 }
29
30 - (void)sendOnChannel:(NSString*)channel
31 message:(NSData*)message
32 binaryReply:(FlutterBinaryReply)callback {
33 if (self.parent) {
34 [self.parent sendOnChannel:channel message:message binaryReply:callback];
35 } else {
36 FML_LOG(WARNING) << "Communicating on a dead channel.";
37 }
38 }
39
40 - (NSObject<FlutterTaskQueue>*)makeBackgroundTaskQueue {
41 if (self.parent) {
42 return [self.parent makeBackgroundTaskQueue];
43 } else {
44 return nil;
45 };
46 }
47
48 - (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(NSString*)channel
49 binaryMessageHandler:
50 (FlutterBinaryMessageHandler)handler {
51 if (self.parent) {
52 return [self.parent setMessageHandlerOnChannel:channel binaryMessageHandler:handler];
53 } else {
54 FML_LOG(WARNING) << "Communicating on a dead channel.";
55 return -1;
56 }
57 }
58
59 - (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(NSString*)channel
60 binaryMessageHandler:(FlutterBinaryMessageHandler)handler
61 taskQueue:
62 (NSObject<FlutterTaskQueue>*)taskQueue {
63 if (self.parent) {
64 return [self.parent setMessageHandlerOnChannel:channel
65 binaryMessageHandler:handler
66 taskQueue:taskQueue];
67 } else {
68 FML_LOG(WARNING) << "Communicating on a dead channel.";
69 return -1;
70 }
71 }
72
73 - (void)cleanUpConnection:(FlutterBinaryMessengerConnection)connection {
74 if (self.parent) {
75 return [self.parent cleanUpConnection:connection];
76 } else {
77 FML_LOG(WARNING) << "Communicating on a dead channel.";
78 }
79 }
80
81 @end
FLUTTER_ASSERT_ARC
#define FLUTTER_ASSERT_ARC
Definition: FlutterMacros.h:44
FlutterBinaryMessageHandler
void(^ FlutterBinaryMessageHandler)(NSData *_Nullable message, FlutterBinaryReply reply)
Definition: FlutterBinaryMessenger.h:30
FlutterBinaryMessengerRelay.h
-[FlutterBinaryMessenger-p makeBackgroundTaskQueue]
NSObject< FlutterTaskQueue > * makeBackgroundTaskQueue()
TODO(gaaclarke): Remove optional when macos supports Background Platform Channels.
FlutterTaskQueue-p
Definition: FlutterBinaryMessengerRelayTest.mm:16
FlutterBinaryMessengerRelay
Definition: FlutterBinaryMessengerRelay.h:14
FlutterBinaryMessenger-p
Definition: FlutterBinaryMessenger.h:48
FlutterBinaryMessengerRelay::parent
NSObject< FlutterBinaryMessenger > * parent
Definition: FlutterBinaryMessengerRelay.h:15
FlutterBinaryMessengerConnection
int64_t FlutterBinaryMessengerConnection
Definition: FlutterBinaryMessenger.h:32
FlutterBinaryReply
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)