未验证 提交 e96e9273 编写于 作者: O openharmony_ci 提交者: Gitee

!22505 翻译完成:21814【资料问题】修复IDL文档中客户端调用接口的错误

Merge pull request !22505 from wusongqing/TR21814
...@@ -62,7 +62,7 @@ sequenceable a.b..C.D ...@@ -62,7 +62,7 @@ sequenceable a.b..C.D
The preceding statement is parsed into the following code in the C++ header file: The preceding statement is parsed into the following code in the C++ header file:
```cpp ```cpp
#include "a/b/d.h" #include "a/b/d.h"
using C::D; using C::D;
``` ```
...@@ -347,11 +347,10 @@ export default { ...@@ -347,11 +347,10 @@ export default {
#### Calling Methods from the Client for IPC #### Calling Methods from the Client for IPC
When the client calls **connectAbility()** to connect to a Service ability, the **onConnect** callback in **onAbilityConnectDone** of the client receives the **IRemoteObject** instance returned by the **onConnect()** method of the Service ability. The client and Service ability are in different applications. Therefore, the directory of the client application must contain a copy of the .idl file (the SDK automatically generates the proxy class). The **onConnect** callback then uses the **IRemoteObject** instance to create the **testProxy** instance of the **IdlTestServiceProxy** class and calls the related IPC method. The sample code is as follows: When the client calls **connectServiceExtensionAbility()** to connect to a Service ability, the **onConnect** callback in **onAbilityConnectDone** of the client receives the **IRemoteObject** instance returned by the **onConnect()** method of the Service ability. The client and Service ability are in different applications. Therefore, the directory of the client application must contain a copy of the .idl file (the SDK automatically generates the proxy class). The **onConnect** callback then uses the **IRemoteObject** instance to create the **testProxy** instance of the **IdlTestServiceProxy** class and calls the related IPC method. The sample code is as follows:
```ts ```ts
import IdlTestServiceProxy from './idl_test_service_proxy' import IdlTestServiceProxy from './idl_test_service_proxy'
import featureAbility from '@ohos.ability.featureAbility';
function callbackTestIntTransaction(result: number, ret: number): void { function callbackTestIntTransaction(result: number, ret: number): void {
if (result == 0 && ret == 124) { if (result == 0 && ret == 124) {
...@@ -396,13 +395,13 @@ var onAbilityConnectDone = { ...@@ -396,13 +395,13 @@ var onAbilityConnectDone = {
} }
}; };
function connectAbility: void { function connectAbility(): void {
let want = { let want = {
bundleName: 'com.example.myapplicationidl', bundleName: 'com.example.myapplicationidl',
abilityName: 'com.example.myapplicationidl.ServiceAbility' abilityName: 'com.example.myapplicationidl.ServiceAbility'
}; };
let connectionId = -1; let connectionId = -1;
connectionId = featureAbility.connectAbility(want, onAbilityConnectDone); connectionId = this.context.connectServiceExtensionAbility(want, onAbilityConnectDone);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册