Flutter iOS Embedder
FlutterChannels.mm File Reference

Go to the source code of this file.

Functions

static void ResizeChannelBuffer (NSObject< FlutterBinaryMessenger > *binaryMessenger, NSString *channel, NSInteger newSize)
 
static void SetWarnsOnOverflow (NSObject< FlutterBinaryMessenger > *binaryMessenger, NSString *channel, BOOL warns)
 
static FlutterBinaryMessengerConnection SetMessageHandler (NSObject< FlutterBinaryMessenger > *messenger, NSString *name, FlutterBinaryMessageHandler handler, NSObject< FlutterTaskQueue > *taskQueue)
 

Variables

static FLUTTER_ASSERT_ARC NSString *const kFlutterChannelBuffersChannel = @"@"dev.flutter/channel-buffers"
 
static NSString *const kResizeMethod = @"@"resize"
 
static NSString *const kOverflowMethod = @"@"overflow"
 
NSString * _name
 
NSObject< FlutterMessageCodec > * _codec
 
FlutterBinaryMessengerConnection _connection
 
NSObject< FlutterTaskQueue > * _taskQueue
 

Function Documentation

◆ ResizeChannelBuffer()

static void ResizeChannelBuffer ( NSObject< FlutterBinaryMessenger > *  binaryMessenger,
NSString *  channel,
NSInteger  newSize 
)
static

Definition at line 15 of file FlutterChannels.mm.

17  {
18  NSCAssert(newSize >= 0, @"Channel buffer size must be non-negative");
19  // Cast newSize to int because the deserialization logic handles only 32 bits values,
20  // see
21  // https://github.com/flutter/engine/blob/93e8901490e78c7ba7e319cce4470d9c6478c6dc/lib/ui/channel_buffers.dart#L495.
22  NSArray* args = @[ channel, @(static_cast<int>(newSize)) ];
23  FlutterMethodCall* resizeMethodCall = [FlutterMethodCall methodCallWithMethodName:kResizeMethod
24  arguments:args];
25  NSObject<FlutterMethodCodec>* codec = [FlutterStandardMethodCodec sharedInstance];
26  NSData* message = [codec encodeMethodCall:resizeMethodCall];
27  [binaryMessenger sendOnChannel:kFlutterChannelBuffersChannel message:message];
28 }

References kFlutterChannelBuffersChannel, and kResizeMethod.

Referenced by FlutterBasicMessageChannel::resizeChannelBuffer:, and FlutterBasicMessageChannel::resizeChannelWithName:binaryMessenger:size:.

◆ SetMessageHandler()

static FlutterBinaryMessengerConnection SetMessageHandler ( NSObject< FlutterBinaryMessenger > *  messenger,
NSString *  name,
FlutterBinaryMessageHandler  handler,
NSObject< FlutterTaskQueue > *  taskQueue 
)
static

Definition at line 50 of file FlutterChannels.mm.

54  {
55  if (taskQueue) {
56  NSCAssert([messenger respondsToSelector:@selector(setMessageHandlerOnChannel:
57  binaryMessageHandler:taskQueue:)],
58  @"");
59  return [messenger setMessageHandlerOnChannel:name
60  binaryMessageHandler:handler
61  taskQueue:taskQueue];
62  } else {
63  return [messenger setMessageHandlerOnChannel:name binaryMessageHandler:handler];
64  }
65 }

◆ SetWarnsOnOverflow()

static void SetWarnsOnOverflow ( NSObject< FlutterBinaryMessenger > *  binaryMessenger,
NSString *  channel,
BOOL  warns 
)
static

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

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

Definition at line 39 of file FlutterChannels.mm.

41  {
42  FlutterMethodCall* overflowMethodCall =
43  [FlutterMethodCall methodCallWithMethodName:kOverflowMethod
44  arguments:@[ channel, @(!warns) ]];
45  NSObject<FlutterMethodCodec>* codec = [FlutterStandardMethodCodec sharedInstance];
46  NSData* message = [codec encodeMethodCall:overflowMethodCall];
47  [binaryMessenger sendOnChannel:kFlutterChannelBuffersChannel message:message];
48 }

References kFlutterChannelBuffersChannel, and kOverflowMethod.

Referenced by FlutterBasicMessageChannel::setWarnsOnOverflow:, and FlutterBasicMessageChannel::setWarnsOnOverflow:forChannelWithName:binaryMessenger:.

Variable Documentation

◆ _codec

NSObject<FlutterMessageCodec>* _codec

Definition at line 71 of file FlutterChannels.mm.

◆ _connection

Definition at line 72 of file FlutterChannels.mm.

◆ _name

NSString* _name
Initial value:
{
NSObject<FlutterBinaryMessenger>* _messenger

Definition at line 68 of file FlutterChannels.mm.

Referenced by FlutterEngineGroup::initWithName:project:, FlutterBasicMessageChannel::resizeChannelBuffer:, and FlutterBasicMessageChannel::setWarnsOnOverflow:.

◆ _taskQueue

NSObject<FlutterTaskQueue>* _taskQueue

Definition at line 73 of file FlutterChannels.mm.

◆ kFlutterChannelBuffersChannel

FLUTTER_ASSERT_ARC NSString* const kFlutterChannelBuffersChannel = @"@"dev.flutter/channel-buffers"
static

Definition at line 11 of file FlutterChannels.mm.

Referenced by ResizeChannelBuffer(), and SetWarnsOnOverflow().

◆ kOverflowMethod

NSString* const kOverflowMethod = @"@"overflow"
static

◆ kResizeMethod

NSString* const kResizeMethod = @"@"resize"
static

Definition at line 12 of file FlutterChannels.mm.

Referenced by flutter::internal::ResizeChannel(), and ResizeChannelBuffer().

kOverflowMethod
static NSString *const kOverflowMethod
Definition: FlutterChannels.mm:13
kResizeMethod
static NSString *const kResizeMethod
Definition: FlutterChannels.mm:12
FlutterMethodCall
Definition: FlutterCodecs.h:220
kFlutterChannelBuffersChannel
static FLUTTER_ASSERT_ARC NSString *const kFlutterChannelBuffersChannel
Definition: FlutterChannels.mm:11
FlutterStandardMethodCodec
Definition: FlutterCodecs.h:469