Flutter Engine
FlutterBasicMessageChannel Class Reference

#import <FlutterChannels.h>

Inheritance diagram for FlutterBasicMessageChannel:

Instance Methods

(instancetype) - initWithName:binaryMessenger:codec:
 
(void) - sendMessage:
 
(void) - sendMessage:reply:
 
(void) - setMessageHandler:
 
(void) - resizeChannelBuffer:
 

Class Methods

(instancetype) + messageChannelWithName:binaryMessenger:
 
(instancetype) + messageChannelWithName:binaryMessenger:codec:
 

Detailed Description

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

Definition at line 36 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 40 of file FlutterChannels.mm.

References _codec, _connection, _name, FlutterBinaryReply, and FlutterReply.

40  :(NSString*)name
41  binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
42  codec:(NSObject<FlutterMessageCodec>*)codec {
43  self = [super init];
44  NSAssert(self, @"Super init cannot be nil");
45  _name = [name retain];
46  _messenger = [messenger retain];
47  _codec = [codec retain];
48  return self;
49 }
NSString * _name
const char * name
Definition: fuchsia.cc:50
NSObject< FlutterMessageCodec > * _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 25 of file FlutterChannels.mm.

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

25  :(NSString*)name
26  binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger {
27  NSObject<FlutterMessageCodec>* codec = [FlutterStandardMessageCodec sharedInstance];
29  binaryMessenger:messenger
30  codec:codec];
31 }
instancetype messageChannelWithName:binaryMessenger:codec:(NSString *name, [binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger, [codec] NSObject< FlutterMessageCodec > *codec)
instancetype sharedInstance()
const char * name
Definition: fuchsia.cc:50

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

Referenced by FlutterViewController::initWithProject:, and messageChannelWithName:binaryMessenger:.

32  :(NSString*)name
33  binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
34  codec:(NSObject<FlutterMessageCodec>*)codec {
35  return [[[FlutterBasicMessageChannel alloc] initWithName:name
36  binaryMessenger:messenger
37  codec:codec] autorelease];
38 }
const char * name
Definition: fuchsia.cc:50

◆ resizeChannelBuffer:()

- (void) resizeChannelBuffer: (NSInteger)  newSize

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

Definition at line 90 of file FlutterChannels.mm.

References _name, FlutterMethodCall::arguments, FlutterError::code, FlutterError::details, id, FlutterError::message, FlutterMethodCall::method, and ResizeChannelBuffer().

90  :(NSInteger)newSize {
91  ResizeChannelBuffer(_messenger, _name, newSize);
92 }
static void ResizeChannelBuffer(NSObject< FlutterBinaryMessenger > *binaryMessenger, NSString *channel, NSInteger newSize)
NSString * _name

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

Referenced by FlutterEngine::ensureSemanticsEnabled.

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

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

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