Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
a62f4649
D
Docs
项目概览
OpenHarmony
/
Docs
11 个月 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a62f4649
编写于
6月 14, 2023
作者:
X
xujie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复工具扫描问题
Signed-off-by:
N
xujie
<
xujie223@huawei.com
>
上级
ef50de49
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
16 deletion
+24
-16
zh-cn/application-dev/reference/apis/js-apis-net-mdns.md
zh-cn/application-dev/reference/apis/js-apis-net-mdns.md
+12
-4
zh-cn/application-dev/reference/apis/js-apis-socket.md
zh-cn/application-dev/reference/apis/js-apis-socket.md
+12
-12
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-net-mdns.md
浏览文件 @
a62f4649
...
...
@@ -629,7 +629,7 @@ FA模型示例:
// 获取context
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
let
serviceType
=
"
_print._tcp
"
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
context
,
serviceType
);
discoveryService
.
startSearchingMDNS
();
```
...
...
@@ -645,7 +645,7 @@ class EntryAbility extends UIAbility {
}
}
let
context
=
globalThis
.
context
;
let
serviceType
=
"
_print._tcp
"
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
context
,
serviceType
);
discoveryService
.
startSearchingMDNS
();
```
...
...
@@ -666,7 +666,7 @@ FA模型示例:
// 获取context
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
let
serviceType
=
"
_print._tcp
"
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
context
,
serviceType
);
discoveryService
.
stopSearchingMDNS
();
```
...
...
@@ -682,7 +682,7 @@ class EntryAbility extends UIAbility {
}
}
let
context
=
globalThis
.
context
;
let
serviceType
=
"
_print._tcp
"
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
context
,
serviceType
);
discoveryService
.
stopSearchingMDNS
();
```
...
...
@@ -706,6 +706,8 @@ on(type: 'discoveryStart', callback: Callback<{serviceInfo: LocalServiceInfo, er
```
js
// 参考mdns.createDiscoveryService
let
context
=
globalThis
.
context
;
let
serviceType
=
"
_print._tcp
"
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
context
,
serviceType
);
discoveryService
.
startSearchingMDNS
();
...
...
@@ -735,6 +737,8 @@ on(type: 'discoveryStop', callback: Callback<{serviceInfo: LocalServiceInfo, err
```
js
// 参考mdns.createDiscoveryService
let
context
=
globalThis
.
context
;
let
serviceType
=
"
_print._tcp
"
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
context
,
serviceType
);
discoveryService
.
startSearchingMDNS
();
...
...
@@ -764,6 +768,8 @@ on(type: 'serviceFound', callback: Callback\<LocalServiceInfo>): void
```
js
// 参考mdns.createDiscoveryService
let
context
=
globalThis
.
context
;
let
serviceType
=
"
_print._tcp
"
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
context
,
serviceType
);
discoveryService
.
startSearchingMDNS
();
...
...
@@ -793,6 +799,8 @@ on(type: 'serviceLost', callback: Callback\<LocalServiceInfo>): void
```
js
// 参考mdns.createDiscoveryService
let
context
=
globalThis
.
context
;
let
serviceType
=
"
_print._tcp
"
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
context
,
serviceType
);
discoveryService
.
startSearchingMDNS
();
...
...
zh-cn/application-dev/reference/apis/js-apis-socket.md
浏览文件 @
a62f4649
...
...
@@ -479,12 +479,12 @@ on(type: 'message', callback: Callback\<{message: ArrayBuffer, remoteInfo: Socke
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
messageView
=
''
;
udp
.
on
(
'
message
'
,
value
=>
{
for
(
var
i
=
0
;
i
<
value
.
message
.
length
;
i
++
)
{
let
messages
=
value
.
message
[
i
]
let
message
=
String
.
fromCharCode
(
messages
);
let
messageView
=
''
;
messageView
+=
item
;
messageView
+=
value
;
}
console
.
log
(
'
on message message:
'
+
JSON
.
stringify
(
messageView
));
console
.
log
(
'
remoteInfo:
'
+
JSON
.
stringify
(
value
.
remoteInfo
));
...
...
@@ -513,12 +513,12 @@ off(type: 'message', callback?: Callback\<{message: ArrayBuffer, remoteInfo: Soc
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
messageView
=
''
;
let
callback
=
value
=>
{
for
(
var
i
=
0
;
i
<
value
.
message
.
length
;
i
++
)
{
let
messages
=
value
.
message
[
i
]
let
message
=
String
.
fromCharCode
(
messages
);
let
messageView
=
''
;
messageView
+=
item
;
messageView
+=
value
;
}
console
.
log
(
'
on message message:
'
+
JSON
.
stringify
(
messageView
));
console
.
log
(
'
remoteInfo:
'
+
JSON
.
stringify
(
value
.
remoteInfo
));
...
...
@@ -1365,12 +1365,12 @@ on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: Socket
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
messageView
=
''
;
tcp
.
on
(
'
message
'
,
value
=>
{
for
(
var
i
=
0
;
i
<
value
.
message
.
length
;
i
++
)
{
let
messages
=
value
.
message
[
i
]
let
message
=
String
.
fromCharCode
(
messages
);
let
messageView
=
''
;
messageView
+=
item
;
messageView
+=
value
;
}
console
.
log
(
'
on message message:
'
+
JSON
.
stringify
(
messageView
));
console
.
log
(
'
remoteInfo:
'
+
JSON
.
stringify
(
value
.
remoteInfo
));
...
...
@@ -1399,12 +1399,12 @@ off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: Sock
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
messageView
=
''
;
let
callback
=
value
=>
{
for
(
var
i
=
0
;
i
<
value
.
message
.
length
;
i
++
)
{
let
messages
=
value
.
message
[
i
]
let
message
=
String
.
fromCharCode
(
messages
);
let
messageView
=
''
;
messageView
+=
item
;
messageView
+=
value
;
}
console
.
log
(
'
on message message:
'
+
JSON
.
stringify
(
messageView
));
console
.
log
(
'
remoteInfo:
'
+
JSON
.
stringify
(
value
.
remoteInfo
));
...
...
@@ -1888,12 +1888,12 @@ on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: Socket
```
js
let
tls
=
socket
.
constructTLSSocketInstance
();
let
messageView
=
''
;
tls
.
on
(
'
message
'
,
value
=>
{
for
(
var
i
=
0
;
i
<
value
.
message
.
length
;
i
++
)
{
let
messages
=
value
.
message
[
i
]
let
message
=
String
.
fromCharCode
(
messages
);
let
messageView
=
''
;
messageView
+=
item
;
messageView
+=
value
;
}
console
.
log
(
'
on message message:
'
+
JSON
.
stringify
(
messageView
));
console
.
log
(
'
remoteInfo:
'
+
JSON
.
stringify
(
value
.
remoteInfo
));
...
...
@@ -1922,12 +1922,12 @@ off(type: 'message', callback?: Callback\<{message: ArrayBuffer, remoteInfo: Soc
```
js
let
tls
=
socket
.
constructTLSSocketInstance
();
let
messageView
=
''
;
let
callback
=
value
=>
{
for
(
var
i
=
0
;
i
<
value
.
message
.
length
;
i
++
)
{
let
messages
=
value
.
message
[
i
]
let
message
=
String
.
fromCharCode
(
messages
);
let
messageView
=
''
;
messageView
+=
item
;
messageView
+=
value
;
}
console
.
log
(
'
on message message:
'
+
JSON
.
stringify
(
messageView
));
console
.
log
(
'
remoteInfo:
'
+
JSON
.
stringify
(
value
.
remoteInfo
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录