Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
c3d1e9e9
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
9 个月 前同步成功
通知
166
Star
19623
Fork
3062
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DoraemonKit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
c3d1e9e9
编写于
6月 24, 2022
作者:
C
Chason Tang
提交者:
GitHub
6月 24, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(iOS): Complete TCP mock logic. (#1053)
1. Fix xPath become nil error.
上级
23c7bc0b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
4 deletion
+40
-4
iOS/DoKit/Classes/Foundation/DKMultiControlStreamManager.h
iOS/DoKit/Classes/Foundation/DKMultiControlStreamManager.h
+5
-1
iOS/DoKit/Classes/Foundation/DKMultiControlStreamManager.m
iOS/DoKit/Classes/Foundation/DKMultiControlStreamManager.m
+27
-3
iOS/DoKit/Classes/Foundation/DTO/DKCommonDTOModel.h
iOS/DoKit/Classes/Foundation/DTO/DKCommonDTOModel.h
+2
-0
iOS/DoKit/Classes/Foundation/DTO/DKCommonDTOModel.m
iOS/DoKit/Classes/Foundation/DTO/DKCommonDTOModel.m
+2
-0
iOS/DoraemonKit/Src/MultiControl/Function/EventSync/MessagePackager/DoraemonMCMessagePackager.m
...ion/EventSync/MessagePackager/DoraemonMCMessagePackager.m
+4
-0
未找到文件。
iOS/DoKit/Classes/Foundation/DKMultiControlStreamManager.h
浏览文件 @
c3d1e9e9
...
...
@@ -34,7 +34,9 @@ typedef NS_ENUM(NSUInteger, DKMultiControlStreamManagerState) {
/// @brief Main thread.
@interface
DKMultiControlStreamManager
:
NSObject
@property
(
nonatomic
,
nullable
,
copy
)
NSString
*
_Nullable
(
^
searchIdConstructor
)(
NSURL
*
url
);
@property
(
nonatomic
,
nullable
,
copy
)
NSString
*
(
^
searchIdConstructor
)(
NSURL
*
url
);
@property
(
nonatomic
,
nullable
,
copy
)
void
(
^
tcpHandler
)(
NSString
*
_Nullable
message
);
@property
(
readonly
)
DKMultiControlStreamManagerState
state
;
...
...
@@ -60,6 +62,8 @@ typedef NS_ENUM(NSUInteger, DKMultiControlStreamManagerState) {
-
(
void
)
broadcastWithActionMessage
:(
NSString
*
)
message
;
-
(
void
)
broadcastWithTCPMessage
:(
nullable
NSString
*
)
message
;
@end
NS_ASSUME_NONNULL_END
iOS/DoKit/Classes/Foundation/DKMultiControlStreamManager.m
浏览文件 @
c3d1e9e9
...
...
@@ -29,8 +29,6 @@ static NSString *generateId(void);
static
NSString
*
const
MULTI_CONTROL_HOST
=
@"mc_host"
;
static
NSString
*
const
MULTI_CONTROL_ACTION
=
@"action"
;
//static NSString *const BEHAVIOR_ID = @"68753A444D6F12269C600050E4C00067";
@interface
DKMultiControlStreamManager
()
...
...
@@ -89,7 +87,7 @@ NSString *generateId(void) {
typeof
(
weakSelf
)
self
=
weakSelf
;
if
([
commonDTOModel
.
dataType
isEqualToString
:
MULTI_CONTROL_HOST
])
{
[
self
changeToSlave
];
}
else
if
([
commonDTOModel
.
dataType
isEqualToString
:
MULTI_CONTROL
_ACTION
])
{
}
else
if
([
commonDTOModel
.
dataType
isEqualToString
:
DK
_ACTION
])
{
// Handle behaviorId and process data.
NSData
*
jsonData
=
[
commonDTOModel
.
data
dataUsingEncoding
:
NSUTF8StringEncoding
];
if
(
jsonData
)
{
...
...
@@ -103,6 +101,8 @@ NSString *generateId(void) {
}
}
}
}
else
if
([
commonDTOModel
.
dataType
isEqualToString
:
DK_TCP
])
{
self
.
tcpHandler
?
self
.
tcpHandler
(
commonDTOModel
.
data
)
:
nil
;
}
};
for
(
id
<
DKMultiControlStreamManagerStateListener
>
listener
in
self
.
listenerArray
)
{
...
...
@@ -395,4 +395,28 @@ NSString *generateId(void) {
[
self
.
webSocketSession
sendString
:
dataString
requestId
:
nil
completionHandler
:
nil
];
}
-
(
void
)
broadcastWithTCPMessage
:(
NSString
*
)
message
{
if
(
!
self
.
webSocketSession
)
{
return
;
}
DKCommonDTOModel
*
commonDTOModel
=
[[
DKCommonDTOModel
alloc
]
init
];
commonDTOModel
.
requestId
=
nil
;
commonDTOModel
.
deviceType
=
DK_DEVICE_TYPE
;
commonDTOModel
.
data
=
message
;
commonDTOModel
.
method
=
DK_WEBSOCKET_BROADCAST
;
commonDTOModel
.
connectSerial
=
self
.
webSocketSession
.
sessionUUID
;
commonDTOModel
.
dataType
=
DK_ACTION
;
NSError
*
error
=
nil
;
NSDictionary
*
jsonDictionary
=
[
MTLJSONAdapter
JSONDictionaryFromModel
:
commonDTOModel
error
:
&
error
];
NSData
*
jsonData
=
[
NSJSONSerialization
dataWithJSONObject
:
jsonDictionary
?:
@{}
options
:
0
error
:&
error
];
NSString
*
dataString
=
nil
;
if
(
jsonData
)
{
dataString
=
[[
NSString
alloc
]
initWithData
:
jsonData
encoding
:
NSUTF8StringEncoding
];
}
if
(
!
dataString
)
{
return
;
}
[
self
.
webSocketSession
sendString
:
dataString
requestId
:
nil
completionHandler
:
nil
];
}
@end
iOS/DoKit/Classes/Foundation/DTO/DKCommonDTOModel.h
浏览文件 @
c3d1e9e9
...
...
@@ -32,6 +32,8 @@ extern NSString *DK_DATA_QUERY;
extern
NSString
*
DK_ACTION
;
extern
NSString
*
DK_TCP
;
@interface
DKCommonDTOModel
:
MTLModel
<
MTLJSONSerializing
>
@property
(
nonatomic
,
nullable
,
copy
)
NSNumber
*
requestId
;
...
...
iOS/DoKit/Classes/Foundation/DTO/DKCommonDTOModel.m
浏览文件 @
c3d1e9e9
...
...
@@ -30,6 +30,8 @@ NSString *DK_DATA_QUERY = @"query";
NSString
*
DK_ACTION
=
@"action"
;
NSString
*
DK_TCP
=
@"tcp"
;
@implementation
DKCommonDTOModel
+
(
NSDictionary
*
)
JSONKeyPathsByPropertyKey
{
...
...
iOS/DoraemonKit/Src/MultiControl/Function/EventSync/MessagePackager/DoraemonMCMessagePackager.m
浏览文件 @
c3d1e9e9
...
...
@@ -29,6 +29,10 @@ static NSString const *kcustomTypeKey =@"customType";
DoraemonMCMessage
*
messageInstance
=
[[
DoraemonMCMessage
alloc
]
init
];
messageInstance
.
type
=
type
;
DoraemonMCXPathSerializer
*
xPathInstance
=
[
DoraemonMCXPathSerializer
xPathInstanceWithView
:
view
];
if
(
xPathInstance
.
windowIndex
==
NSNotFound
)
{
// 如果存在埋点 SDK,埋点会被后调用,先前调用的业务 action 关闭了当前页面,导致 sender 不存在于视图中,会出现这种情况。这种情况需要过滤
return
nil
;
}
if
(
xPathInstance
.
ignore
)
{
return
nil
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录