Flutter Engine
The Flutter Engine
Functions | Variables
FlutterChannels.mm File Reference
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"

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}
static NSString *const kResizeMethod
static FLUTTER_ASSERT_ARC NSString *const kFlutterChannelBuffersChannel
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Win32Message message

◆ 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}
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ 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}
static NSString *const kOverflowMethod

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

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

◆ kOverflowMethod

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

Definition at line 13 of file FlutterChannels.mm.

◆ kResizeMethod

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

Definition at line 12 of file FlutterChannels.mm.