Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
a9a763bb
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
未验证
提交
a9a763bb
编写于
11月 03, 2022
作者:
C
crazy_hu
提交者:
Gitee
11月 03, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change onRemotRequestEx to onRemoteMessageRequest
Signed-off-by:
N
crazy_hu
<
huxiusong1@huawei.com
>
上级
97ac9456
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
33 deletion
+33
-33
zh-cn/application-dev/reference/apis/js-apis-rpc.md
zh-cn/application-dev/reference/apis/js-apis-rpc.md
+33
-33
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-rpc.md
浏览文件 @
a9a763bb
...
@@ -3307,7 +3307,7 @@ readInterfaceToken(): string
...
@@ -3307,7 +3307,7 @@ readInterfaceToken(): string
```
```
class Stub extends rpc.RemoteObject {
class Stub extends rpc.RemoteObject {
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
let interfaceToken = data.readInterfaceToken();
let interfaceToken = data.readInterfaceToken();
console.log("RpcServer: interfaceToken is " + interfaceToken);
console.log("RpcServer: interfaceToken is " + interfaceToken);
return true;
return true;
...
@@ -3438,7 +3438,7 @@ getWritableBytes(): number
...
@@ -3438,7 +3438,7 @@ getWritableBytes(): number
```
```
class Stub extends rpc.RemoteObject {
class Stub extends rpc.RemoteObject {
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
let getWritableBytes = data.getWritableBytes();
let getWritableBytes = data.getWritableBytes();
console.log("RpcServer: getWritableBytes is " + getWritableBytes);
console.log("RpcServer: getWritableBytes is " + getWritableBytes);
return true;
return true;
...
@@ -7130,7 +7130,7 @@ static getCallingPid(): number
...
@@ -7130,7 +7130,7 @@ static getCallingPid(): number
```
```
class Stub extends rpc.RemoteObject {
class Stub extends rpc.RemoteObject {
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
let callerPid = rpc.IPCSkeleton.getCallingPid();
let callerPid = rpc.IPCSkeleton.getCallingPid();
console.log("RpcServer: getCallingPid result: " + callerPid);
console.log("RpcServer: getCallingPid result: " + callerPid);
return true;
return true;
...
@@ -7157,7 +7157,7 @@ static getCallingUid(): number
...
@@ -7157,7 +7157,7 @@ static getCallingUid(): number
```
```
class Stub extends rpc.RemoteObject {
class Stub extends rpc.RemoteObject {
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
let callerUid = rpc.IPCSkeleton.getCallingUid();
let callerUid = rpc.IPCSkeleton.getCallingUid();
console.log("RpcServer: getCallingUid result: " + callerUid);
console.log("RpcServer: getCallingUid result: " + callerUid);
return true;
return true;
...
@@ -7185,7 +7185,7 @@ static getCallingTokenId(): number;
...
@@ -7185,7 +7185,7 @@ static getCallingTokenId(): number;
```
```
class Stub extends rpc.RemoteObject {
class Stub extends rpc.RemoteObject {
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
let callerTokenId = rpc.IPCSkeleton.getCallingTokenId();
let callerTokenId = rpc.IPCSkeleton.getCallingTokenId();
console.log("RpcServer: getCallingTokenId result: " + callerTokenId);
console.log("RpcServer: getCallingTokenId result: " + callerTokenId);
return true;
return true;
...
@@ -7212,7 +7212,7 @@ static getCallingDeviceID(): string
...
@@ -7212,7 +7212,7 @@ static getCallingDeviceID(): string
```
```
class Stub extends rpc.RemoteObject {
class Stub extends rpc.RemoteObject {
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
let callerDeviceID = rpc.IPCSkeleton.getCallingDeviceID();
let callerDeviceID = rpc.IPCSkeleton.getCallingDeviceID();
console.log("RpcServer: callerDeviceID is: " + callerDeviceID);
console.log("RpcServer: callerDeviceID is: " + callerDeviceID);
return true;
return true;
...
@@ -7239,7 +7239,7 @@ static getLocalDeviceID(): string
...
@@ -7239,7 +7239,7 @@ static getLocalDeviceID(): string
```
```
class Stub extends rpc.RemoteObject {
class Stub extends rpc.RemoteObject {
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID();
let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID();
console.log("RpcServer: localDeviceID is: " + localDeviceID);
console.log("RpcServer: localDeviceID is: " + localDeviceID);
return true;
return true;
...
@@ -7266,7 +7266,7 @@ static isLocalCalling(): boolean
...
@@ -7266,7 +7266,7 @@ static isLocalCalling(): boolean
```
```
class Stub extends rpc.RemoteObject {
class Stub extends rpc.RemoteObject {
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
let isLocalCalling = rpc.IPCSkeleton.isLocalCalling();
let isLocalCalling = rpc.IPCSkeleton.isLocalCalling();
console.log("RpcServer: isLocalCalling is: " + isLocalCalling);
console.log("RpcServer: isLocalCalling is: " + isLocalCalling);
return true;
return true;
...
@@ -7385,7 +7385,7 @@ static resetCallingIdentity(): string
...
@@ -7385,7 +7385,7 @@ static resetCallingIdentity(): string
```
```
class Stub extends rpc.RemoteObject {
class Stub extends rpc.RemoteObject {
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
let callingIdentity = rpc.IPCSkeleton.resetCallingIdentity();
let callingIdentity = rpc.IPCSkeleton.resetCallingIdentity();
console.log("RpcServer: callingIdentity is: " + callingIdentity);
console.log("RpcServer: callingIdentity is: " + callingIdentity);
return true;
return true;
...
@@ -7412,7 +7412,7 @@ static restoreCallingIdentity(identity : string): void
...
@@ -7412,7 +7412,7 @@ static restoreCallingIdentity(identity : string): void
```
```
class Stub extends rpc.RemoteObject {
class Stub extends rpc.RemoteObject {
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
let callingIdentity = null;
let callingIdentity = null;
try {
try {
callingIdentity = rpc.IPCSkeleton.resetCallingIdentity();
callingIdentity = rpc.IPCSkeleton.resetCallingIdentity();
...
@@ -7452,7 +7452,7 @@ static setCallingIdentity(identity : string): boolean
...
@@ -7452,7 +7452,7 @@ static setCallingIdentity(identity : string): boolean
```
```
class Stub extends rpc.RemoteObject {
class Stub extends rpc.RemoteObject {
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
let callingIdentity = null;
let callingIdentity = null;
try {
try {
callingIdentity = rpc.IPCSkeleton.resetCallingIdentity();
callingIdentity = rpc.IPCSkeleton.resetCallingIdentity();
...
@@ -7818,7 +7818,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
...
@@ -7818,7 +7818,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
### onRemoteRequest<sup>8+(deprecated)</sup>
### onRemoteRequest<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[onRemote
RequestEx](#onremoterequestex
9)类替代。
>从API version 9 开始不再维护,建议使用[onRemote
MessageRequest](#onremotemessagerequest
9)类替代。
onRemoteRequest(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean
onRemoteRequest(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean
...
@@ -7874,14 +7874,14 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里处理
...
@@ -7874,14 +7874,14 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里处理
}
}
```
```
### onRemote
RequestEx
<sup>9+</sup>
### onRemote
MessageRequest
<sup>9+</sup>
onRemote
RequestEx
(code : number, data : MessageSequence, reply: MessageSequence, options : MessageOption): boolean | Promise
\<
boolean>
onRemote
MessageRequest
(code : number, data : MessageSequence, reply: MessageSequence, options : MessageOption): boolean | Promise
\<
boolean>
> **说明:**
> **说明:**
>
>
>* 开发者应优先选择重载onRemote
RequestEx
方法,其中可以自由实现同步和异步的消息处理。
>* 开发者应优先选择重载onRemote
MessageRequest
方法,其中可以自由实现同步和异步的消息处理。
>* 开发者同时重载onRemoteRequest和onRemote
RequestEx方法时,仅onRemoteRequestEx
方法生效。
>* 开发者同时重载onRemoteRequest和onRemote
MessageRequest方法时,仅onRemoteMessageRequest
方法生效。
sendMessageRequest请求的响应处理函数,服务端在该函数里同步或异步地处理请求,回复结果。
sendMessageRequest请求的响应处理函数,服务端在该函数里同步或异步地处理请求,回复结果。
...
@@ -7900,10 +7900,10 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
...
@@ -7900,10 +7900,10 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
| 类型 | 说明 |
| 类型 | 说明 |
| ----------------- | ---------------------------------------------------------------------------------------------- |
| ----------------- | ---------------------------------------------------------------------------------------------- |
| boolean | 若在onRemote
RequestEx
中同步地处理请求,则返回一个布尔值:操作成功,则返回true;否则返回false。 |
| boolean | 若在onRemote
MessageRequest
中同步地处理请求,则返回一个布尔值:操作成功,则返回true;否则返回false。 |
| Promise
\<
boolean> | 若在onRemote
RequestEx
中异步地处理请求,则返回一个Promise对象。 |
| Promise
\<
boolean> | 若在onRemote
MessageRequest
中异步地处理请求,则返回一个Promise对象。 |
**重载onRemote
RequestEx
方法同步处理请求示例:**
**重载onRemote
MessageRequest
方法同步处理请求示例:**
```
ets
```
ets
class MyDeathRecipient {
class MyDeathRecipient {
...
@@ -7920,9 +7920,9 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
...
@@ -7920,9 +7920,9 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
isObjectDead(): boolean {
isObjectDead(): boolean {
return false;
return false;
}
}
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
if (code === 1) {
if (code === 1) {
console.log("RpcServer: sync onRemote
RequestEx
is called");
console.log("RpcServer: sync onRemote
MessageRequest
is called");
return true;
return true;
} else {
} else {
console.log("RpcServer: unknown code: " + code);
console.log("RpcServer: unknown code: " + code);
...
@@ -7932,7 +7932,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
...
@@ -7932,7 +7932,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
}
}
```
```
**重载onRemote
RequestEx
方法异步处理请求示例:**
**重载onRemote
MessageRequest
方法异步处理请求示例:**
```
ets
```
ets
class MyDeathRecipient {
class MyDeathRecipient {
...
@@ -7949,9 +7949,9 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
...
@@ -7949,9 +7949,9 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
isObjectDead(): boolean {
isObjectDead(): boolean {
return false;
return false;
}
}
async onRemote
RequestEx
(code, data, reply, option) {
async onRemote
MessageRequest
(code, data, reply, option) {
if (code === 1) {
if (code === 1) {
console.log("RpcServer: async onRemote
RequestEx
is called");
console.log("RpcServer: async onRemote
MessageRequest
is called");
} else {
} else {
console.log("RpcServer: unknown code: " + code);
console.log("RpcServer: unknown code: " + code);
return false;
return false;
...
@@ -7964,7 +7964,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
...
@@ -7964,7 +7964,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
}
}
```
```
**同时重载onRemote
RequestEx
和onRemoteRequest方法同步处理请求示例:**
**同时重载onRemote
MessageRequest
和onRemoteRequest方法同步处理请求示例:**
```
ets
```
ets
class MyDeathRecipient {
class MyDeathRecipient {
...
@@ -7983,17 +7983,17 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
...
@@ -7983,17 +7983,17 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
}
}
onRemoteRequest(code, data, reply, option) {
onRemoteRequest(code, data, reply, option) {
if (code === 1) {
if (code === 1) {
console.log("RpcServer: sync onRemote
RequestEx
is called");
console.log("RpcServer: sync onRemote
MessageRequest
is called");
return true;
return true;
} else {
} else {
console.log("RpcServer: unknown code: " + code);
console.log("RpcServer: unknown code: " + code);
return false;
return false;
}
}
}
}
// 同时调用仅会执行onRemote
RequestEx
// 同时调用仅会执行onRemote
MessageRequest
onRemote
RequestEx
(code, data, reply, option) {
onRemote
MessageRequest
(code, data, reply, option) {
if (code === 1) {
if (code === 1) {
console.log("RpcServer: async onRemote
RequestEx
is called");
console.log("RpcServer: async onRemote
MessageRequest
is called");
} else {
} else {
console.log("RpcServer: unknown code: " + code);
console.log("RpcServer: unknown code: " + code);
return false;
return false;
...
@@ -8004,7 +8004,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
...
@@ -8004,7 +8004,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
}
}
```
```
**同时重载onRemote
RequestEx
和onRemoteRequest方法异步处理请求示例:**
**同时重载onRemote
MessageRequest
和onRemoteRequest方法异步处理请求示例:**
```
ets
```
ets
class MyDeathRecipient {
class MyDeathRecipient {
...
@@ -8030,10 +8030,10 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
...
@@ -8030,10 +8030,10 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
return false;
return false;
}
}
}
}
// 同时调用仅会执行onRemote
RequestEx
// 同时调用仅会执行onRemote
MessageRequest
async onRemote
RequestEx
(code, data, reply, option) {
async onRemote
MessageRequest
(code, data, reply, option) {
if (code === 1) {
if (code === 1) {
console.log("RpcServer: async onRemote
RequestEx
is called");
console.log("RpcServer: async onRemote
MessageRequest
is called");
} else {
} else {
console.log("RpcServer: unknown code: " + code);
console.log("RpcServer: unknown code: " + code);
return false;
return false;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录