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 - (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(NSString*)channel
39  binaryMessageHandler:
41  if (self.parent) {
42  return [self.parent setMessageHandlerOnChannel:channel binaryMessageHandler:handler];
43  } else {
44  FML_LOG(WARNING) << "Communicating on a dead channel.";
45  return -1;
46  }
47 }
48 
49 - (void)cleanupConnection:(FlutterBinaryMessengerConnection)connection {
50  if (self.parent) {
51  return [self.parent cleanupConnection:connection];
52  } else {
53  FML_LOG(WARNING) << "Communicating on a dead channel.";
54  }
55 }
56 
57 @end
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
#define FML_LOG(severity)
Definition: logging.h:65
void(^ FlutterBinaryMessageHandler)(NSData *_Nullable message, FlutterBinaryReply reply)
int64_t FlutterBinaryMessengerConnection
NSObject< FlutterBinaryMessenger > * parent