| Flutter macOS Embedder |

Instance Methods | Class Methods | List of all members
FlutterBasicMessageChannel Class Reference

`#import <FlutterChannels.h>`

Inheritance diagram for FlutterBasicMessageChannel:

## 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

  name | The channel name.
  messenger | The binary messenger.
  codec | The 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 }

## ◆ 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

  name | The channel name.
  messenger | The binary messenger.
  codec | The message codec.
  taskQueue | The 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

  name | The channel name.
  messenger | The binary messenger.

Definition at line 73 of file FlutterChannels.mm.

75 :(NSString*)name
76 binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger {
77 NSObject<FlutterMessageCodec>* codec = [FlutterStandardMessageCodec sharedInstance];
78 return [FlutterBasicMessageChannel messageChannelWithName:name
79 binaryMessenger:messenger
80 codec:codec];
81 }
FlutterBasicMessageChannel
Definition: FlutterChannels.h:38
+[FlutterBasicMessageChannel messageChannelWithName:binaryMessenger:codec:]
instancetype messageChannelWithName:binaryMessenger:codec:(NSString *name,[binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger,[codec] NSObject< FlutterMessageCodec > *codec)
Definition: FlutterChannels.mm:82
FlutterStandardMessageCodec
Definition: FlutterCodecs.h:209
+[FlutterMessageCodec-p sharedInstance]
instancetype 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

  name | The channel name.
  messenger | The binary messenger.
  codec | The 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

  newSize | The number of messages that will get buffered.

Definition at line 73 of file FlutterChannels.mm.

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

## ◆ 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

  name | The channel name.
  messenger | The binary messenger.
  newSize | The 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 }

## ◆ sendMessage:

- (void) sendMessage: |  | (id _Nullable) | message |

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

Parameters

  message | The 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

  message | The message. Must be supported by the codec of this channel.
  callback | A 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

  handler | The 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

  warns | When 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 }
SetWarnsOnOverflow
static void SetWarnsOnOverflow(NSObject< FlutterBinaryMessenger > *binaryMessenger, NSString *channel, BOOL warns)
Definition: FlutterChannels.mm:39

## ◆ 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

  warns | When false, the channel is expected to overflow and warning messages will not be shown.
  name | The channel name.
  messenger | The 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:

- shell/platform/darwin/common/framework/Headers/FlutterChannels.h
- shell/platform/darwin/common/framework/Source/FlutterChannels.mm