Flutter Engine
The Flutter Engine
Instance Methods | Class Methods | List of all members
FlutterBasicMessageChannel Class Reference

#import <FlutterChannels.h>

Inheritance diagram for FlutterBasicMessageChannel:
FakeMessageChannel

Instance Methods

(instancetype) - initWithName:binaryMessenger:codec:
 
(instancetype) - initWithName:binaryMessenger:codec:taskQueue:
 
(void) - sendMessage:
 
(void) - sendMessage:reply:
 
(void) - setMessageHandler:
 
(void) - resizeChannelBuffer:
 
(void) - setWarnsOnOverflow:
 
(instancetype) - initWithName:binaryMessenger:codec:taskQueue: [implementation]
 
(void) - sendMessage: [implementation]
 
(void) - sendMessage:reply: [implementation]
 
(void) - setMessageHandler: [implementation]
 

Class Methods

(instancetype) + messageChannelWithName:binaryMessenger:
 
(instancetype) + messageChannelWithName:binaryMessenger:codec:
 
(void) + resizeChannelWithName:binaryMessenger:size:
 
(void) + setWarnsOnOverflow:forChannelWithName:binaryMessenger:
 

Detailed Description

A channel for communicating with the Flutter side using basic, asynchronous message passing.

Definition at line 37 of file FlutterChannels.h.

Method Documentation

◆ initWithName:binaryMessenger:codec:

- (instancetype) initWithName: (NSString*)  name
binaryMessenger: (NSObject<FlutterBinaryMessenger>*)  messenger
codec: (NSObject<FlutterMessageCodec>*)  codec 

Initializes a FlutterBasicMessageChannel with the specified name, binary messenger, and message codec.

The channel name logically identifies the channel; identically named channels interfere with each other's communication.

The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by FlutterEngine and FlutterViewController.

Parameters
nameThe channel name.
messengerThe binary messenger.
codecThe message codec.

Definition at line 73 of file FlutterChannels.mm.

90 :(NSString*)name
91 binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
92 codec:(NSObject<FlutterMessageCodec>*)codec {
93 self = [self initWithName:name binaryMessenger:messenger codec:codec taskQueue:nil];
94 return self;
95}
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ initWithName:binaryMessenger:codec:taskQueue: [1/2]

- (instancetype) initWithName: (NSString*)  name
binaryMessenger: (NSObject<FlutterBinaryMessenger>*)  messenger
codec: (NSObject<FlutterMessageCodec>*)  codec
taskQueue: (NSObject<FlutterTaskQueue>*)  taskQueue 
implementation

Definition at line 73 of file FlutterChannels.mm.

97 :(NSString*)name
98 binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
99 codec:(NSObject<FlutterMessageCodec>*)codec
100 taskQueue:(NSObject<FlutterTaskQueue>*)taskQueue {
101 self = [super init];
102 NSAssert(self, @"Super init cannot be nil");
103 _name = [name copy];
104 _messenger = messenger;
105 _codec = codec;
106 _taskQueue = taskQueue;
107 return self;
108}
NSString * _name
NSObject< FlutterMessageCodec > * _codec
NSObject< FlutterTaskQueue > * _taskQueue

◆ initWithName:binaryMessenger:codec:taskQueue: [2/2]

- (instancetype) initWithName: (NSString *)  name
binaryMessenger: (NSObject< FlutterBinaryMessenger > *)  messenger
codec: (NSObject< FlutterMessageCodec > *)  codec
taskQueue: (NSObject< FlutterTaskQueue > *_Nullable)  taskQueue 

Initializes a FlutterBasicMessageChannel with the specified name, binary messenger, and message codec.

The channel name logically identifies the channel; identically named channels interfere with each other's communication.

The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by FlutterEngine and FlutterViewController.

Parameters
nameThe channel name.
messengerThe binary messenger.
codecThe message codec.
taskQueueThe FlutterTaskQueue that executes the handler (see -[FlutterBinaryMessenger makeBackgroundTaskQueue]).

◆ messageChannelWithName:binaryMessenger:

+ (instancetype) messageChannelWithName: (NSString*)  name
binaryMessenger: (NSObject<FlutterBinaryMessenger>*)  messenger 

Creates a FlutterBasicMessageChannel with the specified name and binary messenger.

The channel name logically identifies the channel; identically named channels interfere with each other's communication.

The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by FlutterEngine and FlutterViewController.

The channel uses FlutterStandardMessageCodec to encode and decode messages.

Parameters
nameThe channel name.
messengerThe binary messenger.

Definition at line 73 of file FlutterChannels.mm.

75 :(NSString*)name
76 binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger {
77 NSObject<FlutterMessageCodec>* codec = [FlutterStandardMessageCodec sharedInstance];
79 binaryMessenger:messenger
80 codec:codec];
81}
instancetype messageChannelWithName:binaryMessenger:codec:(NSString *name,[binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger,[codec] NSObject< FlutterMessageCodec > *codec)

◆ messageChannelWithName:binaryMessenger:codec:

+ (instancetype) messageChannelWithName: (NSString*)  name
binaryMessenger: (NSObject<FlutterBinaryMessenger>*)  messenger
codec: (NSObject<FlutterMessageCodec>*)  codec 

Creates a FlutterBasicMessageChannel with the specified name, binary messenger, and message codec.

The channel name logically identifies the channel; identically named channels interfere with each other's communication.

The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by FlutterEngine and FlutterViewController.

Parameters
nameThe channel name.
messengerThe binary messenger.
codecThe message codec.

Definition at line 73 of file FlutterChannels.mm.

82 :(NSString*)name
83 binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
84 codec:(NSObject<FlutterMessageCodec>*)codec {
85 return [[FlutterBasicMessageChannel alloc] initWithName:name
86 binaryMessenger:messenger
87 codec:codec];
88}

◆ resizeChannelBuffer:

- (void) resizeChannelBuffer: (NSInteger)  newSize

Adjusts the number of messages that will get buffered when sending messages to channels that aren't fully set up yet. For example, the engine isn't running yet or the channel's message handler isn't set up on the Dart side yet.

Parameters
newSizeThe number of messages that will get buffered.

Definition at line 73 of file FlutterChannels.mm.

152 :(NSInteger)newSize {
153 ResizeChannelBuffer(_messenger, _name, newSize);
154}
static void ResizeChannelBuffer(NSObject< FlutterBinaryMessenger > *binaryMessenger, NSString *channel, NSInteger newSize)

◆ resizeChannelWithName:binaryMessenger:size:

+ (void) resizeChannelWithName: (NSString*)  name
binaryMessenger: (NSObject<FlutterBinaryMessenger>*)  messenger
size: (NSInteger)  newSize 

Adjusts the number of messages that will get buffered when sending messages to channels that aren't fully set up yet. For example, the engine isn't running yet or the channel's message handler isn't set up on the Dart side yet.

Parameters
nameThe channel name.
messengerThe binary messenger.
newSizeThe number of messages that will get buffered.

Definition at line 73 of file FlutterChannels.mm.

146 :(NSString*)name
147 binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
148 size:(NSInteger)newSize {
149 ResizeChannelBuffer(messenger, name, newSize);
150}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ sendMessage: [1/2]

- (void) sendMessage: (id _Nullable)  message

Sends the specified message to the Flutter side, ignoring any reply.

Parameters
messageThe message. Must be supported by the codec of this channel.

Reimplemented in FakeMessageChannel.

◆ sendMessage: [2/2]

- (void) sendMessage: (id message
implementation

Definition at line 73 of file FlutterChannels.mm.

110 :(id)message {
111 [_messenger sendOnChannel:_name message:[_codec encode:message]];
112}
Win32Message message
const uintptr_t id

◆ sendMessage:reply: [1/2]

- (void) sendMessage: (id _Nullable)  message
reply: (FlutterReply _Nullable)  callback 

Sends the specified message to the Flutter side, expecting an asynchronous reply.

Parameters
messageThe message. Must be supported by the codec of this channel.
callbackA callback to be invoked with the message reply from Flutter.

Reimplemented in FakeMessageChannel.

◆ sendMessage:reply: [2/2]

- (void) sendMessage: (id message
reply: (FlutterReply callback 
implementation

Definition at line 73 of file FlutterChannels.mm.

115 FlutterBinaryReply reply = ^(NSData* data) {
116 if (callback) {
118 }
119 };
120 [_messenger sendOnChannel:_name message:[_codec encode:message] binaryReply:reply];
121}
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterReply)(id _Nullable reply)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
static DecodeResult decode(std::string path)
Definition: png_codec.cpp:124
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ setMessageHandler: [1/2]

- (void) setMessageHandler: (FlutterMessageHandler _Nullable)  handler

Registers a message handler with this channel.

Replaces any existing handler. Use a nil handler for unregistering the existing handler.

Parameters
handlerThe message handler.

◆ setMessageHandler: [2/2]

- (void) setMessageHandler: (FlutterMessageHandler handler
implementation

Definition at line 73 of file FlutterChannels.mm.

123 :(FlutterMessageHandler)handler {
124 if (!handler) {
125 if (_connection > 0) {
126 [_messenger cleanUpConnection:_connection];
127 _connection = 0;
128 } else {
129 [_messenger setMessageHandlerOnChannel:_name binaryMessageHandler:nil];
130 }
131 return;
132 }
133
134 // Grab reference to avoid retain on self.
135 // `self` might be released before the block, so the block needs to retain the codec to
136 // make sure it is not released with `self`
137 NSObject<FlutterMessageCodec>* codec = _codec;
139 handler([codec decode:message], ^(id reply) {
140 callback([codec encode:reply]);
141 });
142 };
143 _connection = SetMessageHandler(_messenger, _name, messageHandler, _taskQueue);
144}
void(^ FlutterBinaryMessageHandler)(NSData *_Nullable message, FlutterBinaryReply reply)
void(^ FlutterMessageHandler)(id _Nullable message, FlutterReply callback)
FlutterBinaryMessengerConnection _connection
static FlutterBinaryMessengerConnection SetMessageHandler(NSObject< FlutterBinaryMessenger > *messenger, NSString *name, FlutterBinaryMessageHandler handler, NSObject< FlutterTaskQueue > *taskQueue)
static void encode(uint8_t output[16], const uint32_t input[4])
Definition: SkMD5.cpp:240

◆ setWarnsOnOverflow:

- (void) setWarnsOnOverflow: (BOOL warns

Defines whether the channel should show warning messages when discarding messages due to overflow.

Parameters
warnsWhen false, the channel is expected to overflow and warning messages will not be shown.

Definition at line 73 of file FlutterChannels.mm.

162 :(BOOL)warns {
163 SetWarnsOnOverflow(_messenger, _name, warns);
164}
static void SetWarnsOnOverflow(NSObject< FlutterBinaryMessenger > *binaryMessenger, NSString *channel, BOOL warns)
int BOOL
Definition: windows_types.h:37

◆ setWarnsOnOverflow:forChannelWithName:binaryMessenger:

+ (void) setWarnsOnOverflow: (BOOL warns
forChannelWithName: (NSString*)  name
binaryMessenger: (NSObject<FlutterBinaryMessenger>*)  messenger 

Defines whether the channel should show warning messages when discarding messages due to overflow.

Parameters
warnsWhen false, the channel is expected to overflow and warning messages will not be shown.
nameThe channel name.
messengerThe binary messenger.

Definition at line 73 of file FlutterChannels.mm.

156 :(BOOL)warns
157 forChannelWithName:(NSString*)name
158 binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger {
159 SetWarnsOnOverflow(messenger, name, warns);
160}

The documentation for this class was generated from the following files: