Flutter Engine
The Flutter Engine
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
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
41 if (self.parent) {
42 return [self.parent makeBackgroundTaskQueue];
43 } else {
44 return nil;
45 };
46}
47
48- (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(NSString*)channel
49 binaryMessageHandler:
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
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
void(^ FlutterBinaryMessageHandler)(NSData *_Nullable message, FlutterBinaryReply reply)
int64_t FlutterBinaryMessengerConnection
#define FML_LOG(severity)
Definition: logging.h:82
NSObject< FlutterBinaryMessenger > * parent
NSObject< FlutterTaskQueue > * makeBackgroundTaskQueue()
TODO(gaaclarke): Remove optional when macos supports Background Platform Channels.