Flutter macOS Embedder
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:
 

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 90 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 }

References initWithName:binaryMessenger:codec:taskQueue:.

◆ initWithName:binaryMessenger:codec:taskQueue:

- (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]).

Referenced by initWithName:binaryMessenger:codec:.

◆ 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 75 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 }

References messageChannelWithName:binaryMessenger:codec:, and <FlutterMessageCodec>::sharedInstance.

◆ 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 82 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 }

Referenced by FlutterKeyboardManager::initWithViewDelegate:, and messageChannelWithName:binaryMessenger:.

◆ 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 152 of file FlutterChannels.mm.

152  :(NSInteger)newSize {
153  ResizeChannelBuffer(_messenger, _name, newSize);
154 }

References _name, and ResizeChannelBuffer().

◆ 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 146 of file FlutterChannels.mm.

146  :(NSString*)name
147  binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
148  size:(NSInteger)newSize {
149  ResizeChannelBuffer(messenger, name, newSize);
150 }

References ResizeChannelBuffer().

◆ sendMessage:

- (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:reply:

- (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.

◆ setMessageHandler:

- (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.

Referenced by flutter::testing::TEST_F().

◆ 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 162 of file FlutterChannels.mm.

162  :(BOOL)warns {
163  SetWarnsOnOverflow(_messenger, _name, warns);
164 }

References _name, and SetWarnsOnOverflow().

◆ 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 156 of file FlutterChannels.mm.

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

References SetWarnsOnOverflow().


The documentation for this class was generated from the following files:
+[FlutterBasicMessageChannel messageChannelWithName:binaryMessenger:codec:]
instancetype messageChannelWithName:binaryMessenger:codec:(NSString *name,[binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger,[codec] NSObject< FlutterMessageCodec > *codec)
Definition: FlutterChannels.mm:82
FlutterBasicMessageChannel
Definition: FlutterChannels.h:37
FlutterStandardMessageCodec
Definition: FlutterCodecs.h:209
ResizeChannelBuffer
static void ResizeChannelBuffer(NSObject< FlutterBinaryMessenger > *binaryMessenger, NSString *channel, NSInteger newSize)
Definition: FlutterChannels.mm:15
SetWarnsOnOverflow
static void SetWarnsOnOverflow(NSObject< FlutterBinaryMessenger > *binaryMessenger, NSString *channel, BOOL warns)
Definition: FlutterChannels.mm:39
_name
NSString * _name
Definition: FlutterChannels.mm:68
+[FlutterMessageCodec-p sharedInstance]
instancetype sharedInstance()