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