Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
330b0f02
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
330b0f02
编写于
7月 25, 2019
作者:
F
Francisco Magdaleno
提交者:
GitHub
7月 25, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "[macos] Revert check on FlutterCodecs and refactor message function] (#10009)" (#10141)
This reverts commit
bd387021
.
上级
250ee316
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
35 deletion
+38
-35
shell/platform/darwin/common/framework/Source/FlutterChannels.mm
...latform/darwin/common/framework/Source/FlutterChannels.mm
+1
-1
shell/platform/darwin/common/framework/Source/FlutterCodecs.mm
.../platform/darwin/common/framework/Source/FlutterCodecs.mm
+1
-1
shell/platform/darwin/macos/framework/Source/FLEEngine.mm
shell/platform/darwin/macos/framework/Source/FLEEngine.mm
+36
-33
未找到文件。
shell/platform/darwin/common/framework/Source/FlutterChannels.mm
浏览文件 @
330b0f02
...
...
@@ -51,7 +51,7 @@
-
(
void
)
sendMessage
:(
id
)
message
reply
:(
FlutterReply
)
callback
{
FlutterBinaryReply
reply
=
^
(
NSData
*
data
)
{
if
(
callback
)
callback
(
data
.
length
>
0
?
[
_codec
decode
:
data
]
:
nil
);
callback
(
[
_codec
decode
:
data
]
);
};
[
_messenger
sendOnChannel
:
_name
message
:[
_codec
encode
:
message
]
binaryReply
:
reply
];
}
...
...
shell/platform/darwin/common/framework/Source/FlutterCodecs.mm
浏览文件 @
330b0f02
...
...
@@ -73,7 +73,7 @@
}
-
(
id
)
decode
:(
NSData
*
)
message
{
if
(
message
==
nil
)
if
(
message
.
length
==
0
)
return
nil
;
BOOL
isSimpleValue
=
NO
;
id
decoded
=
nil
;
...
...
shell/platform/darwin/macos/framework/Source/FLEEngine.mm
浏览文件 @
330b0f02
...
...
@@ -332,35 +332,42 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FLEEngine*
#pragma mark - FlutterBinaryMessenger
-
(
void
)
sendOnChannel
:(
nonnull
NSString
*
)
channel
message
:(
nullable
NSData
*
)
message
{
[
self
sendOnChannel
:
channel
message
:
message
binaryReply
:
nil
];
FlutterPlatformMessage
platformMessage
=
{
.
struct_size
=
sizeof
(
FlutterPlatformMessage
),
.
channel
=
[
channel
UTF8String
],
.
message
=
static_cast
<
const
uint8_t
*>
(
message
.
bytes
),
.
message_size
=
message
.
length
,
};
FlutterEngineResult
result
=
FlutterEngineSendPlatformMessage
(
_engine
,
&
platformMessage
);
if
(
result
!=
kSuccess
)
{
NSLog
(
@"Failed to send message to Flutter engine on channel '%@' (%d)."
,
channel
,
result
);
}
}
-
(
void
)
sendOnChannel
:(
NSString
*
)
channel
message
:(
NSData
*
_Nullable
)
message
binaryReply
:(
FlutterBinaryReply
_Nullable
)
callback
{
FlutterPlatformMessageResponseHandle
*
response_handle
=
nullptr
;
if
(
callback
)
{
struct
Captures
{
FlutterBinaryReply
reply
;
};
auto
captures
=
std
::
make_unique
<
Captures
>
();
captures
->
reply
=
callback
;
auto
message_reply
=
[](
const
uint8_t
*
data
,
size_t
data_size
,
void
*
user_data
)
{
auto
captures
=
reinterpret_cast
<
Captures
*>
(
user_data
);
NSData
*
reply_data
=
[
NSData
dataWithBytes
:
static_cast
<
const
void
*>
(
data
)
length
:
data_size
];
captures
->
reply
(
reply_data
);
delete
captures
;
};
struct
Captures
{
FlutterBinaryReply
reply
;
};
auto
captures
=
std
::
make_unique
<
Captures
>
();
captures
->
reply
=
callback
;
auto
message_reply
=
[](
const
uint8_t
*
data
,
size_t
data_size
,
void
*
user_data
)
{
auto
captures
=
reinterpret_cast
<
Captures
*>
(
user_data
);
NSData
*
reply_data
=
[
NSData
dataWithBytes
:(
void
*
)
data
length
:
data_size
];
captures
->
reply
(
reply_data
);
delete
captures
;
};
FlutterEngineResult
create_result
=
FlutterPlatformMessageCreateResponseHandle
(
_engine
,
message_reply
,
captures
.
get
(),
&
response_handle
);
if
(
create_result
!=
kSuccess
)
{
NSLog
(
@"Failed to create a FlutterPlatformMessageResponseHandle (%d)"
,
create_result
);
return
;
}
captures
.
release
();
FlutterPlatformMessageResponseHandle
*
response_handle
=
nullptr
;
FlutterEngineResult
result
=
FlutterPlatformMessageCreateResponseHandle
(
_engine
,
message_reply
,
captures
.
get
(),
&
response_handle
);
if
(
result
!=
kSuccess
)
{
NSLog
(
@"Failed to create a FlutterPlatformMessageResponseHandle"
);
return
;
}
captures
.
release
();
FlutterPlatformMessage
platformMessage
=
{
.
struct_size
=
sizeof
(
FlutterPlatformMessage
),
...
...
@@ -370,19 +377,15 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FLEEngine*
.
response_handle
=
response_handle
,
};
FlutterEngineResult
message_result
=
FlutterEngineSendPlatformMessage
(
_engine
,
&
platformMessage
);
if
(
message_result
!=
kSuccess
)
{
NSLog
(
@"Failed to send message to Flutter engine on channel '%@' (%d)."
,
channel
,
message_result
);
result
=
FlutterEngineSendPlatformMessage
(
_engine
,
&
platformMessage
);
if
(
result
!=
kSuccess
)
{
NSLog
(
@"Failed to send message to Flutter engine on channel '%@' (%d)."
,
channel
,
result
);
}
if
(
response_handle
!=
nullptr
)
{
FlutterEngineResult
release_result
=
FlutterPlatformMessageReleaseResponseHandle
(
_engine
,
response_handle
);
if
(
release_result
!=
kSuccess
)
{
NSLog
(
@"Failed to release the response handle (%d)."
,
release_result
);
};
}
result
=
FlutterPlatformMessageReleaseResponseHandle
(
_engine
,
response_handle
);
if
(
result
!=
kSuccess
)
{
NSLog
(
@"Failed to release the response handle"
);
};
}
-
(
void
)
setMessageHandlerOnChannel
:(
nonnull
NSString
*
)
channel
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录