| 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 #import "flutter/shell/platform/darwin/common/InternalFlutterSwiftCommon/InternalFlutterSwiftCommon.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 [FlutterLogger logWarning:@"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 [FlutterLogger logWarning:@"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 [FlutterLogger logWarning:@"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 [FlutterLogger logWarning:@"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 [FlutterLogger logWarning:@"Communicating on a dead channel."];
78 }
79 }
80
81 @end
FlutterBinaryReply
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
FlutterBinaryMessageHandler
void(^ FlutterBinaryMessageHandler)(NSData *_Nullable message, FlutterBinaryReply reply)
Definition: FlutterBinaryMessenger.h:30
FlutterBinaryMessengerConnection
int64_t FlutterBinaryMessengerConnection
Definition: FlutterBinaryMessenger.h:32
FlutterBinaryMessengerRelay.h
FLUTTER_ASSERT_ARC
#define FLUTTER_ASSERT_ARC
Definition: FlutterMacros.h:44
FlutterBinaryMessengerRelay
Definition: FlutterBinaryMessengerRelay.h:14
FlutterBinaryMessengerRelay::parent
NSObject< FlutterBinaryMessenger > * parent
Definition: FlutterBinaryMessengerRelay.h:15
FlutterBinaryMessenger-p
Definition: FlutterBinaryMessenger.h:49
-[FlutterBinaryMessenger-p makeBackgroundTaskQueue]
NSObject< FlutterTaskQueue > * makeBackgroundTaskQueue()
TODO(gaaclarke): Remove optional when macos supports Background Platform Channels.
FlutterTaskQueue-p
Definition: FlutterBinaryMessenger.h:34