mirror of
https://github.com/openharmony/communication_communication_cangjie_wrapper.git
synced 2026-07-01 21:54:01 -04:00
@@ -1,36 +1,38 @@
|
||||
# communication_cangjie_wrapper
|
||||
# Distributed Soft Bus Cangjie Wrapper
|
||||
|
||||
## Introduction
|
||||
|
||||
The distributed soft bus subsystem is designed to provide communication-related capabilities for the OpenHarmony system. The currently open distributed soft bus Cangjie interface only supports standard devices.
|
||||
In the OpenHarmony platform, the distributed soft bus Cangjie wrapper provides developers with cross-process communication capabilities needed for application development using the Cangjie language. IPC (Inter-Process Communication) and RPC (Remote Procedure Call) mechanisms are used to implement cross-process communication. The former uses the Binder driver for cross-process communication within a device, while the latter uses the soft bus driver for cross-device cross-process communication. Typical IPC scenarios are in background services, where the application's background service provides cross-process service invocation capabilities through the IPC mechanism. Typical RPC usage scenarios are in multi-end collaboration, where multi-end collaboration provides remote interface invocation and data transmission capabilities through the RPC mechanism. Currently, the open distributed soft bus Cangjie interface only supports standard devices.
|
||||
|
||||
## System Architecture
|
||||
|
||||
**Figure 1** Diagram of the Cangjie architecture of distributed soft bus
|
||||
|
||||

|
||||

|
||||
|
||||
As shown in the architecture diagram:
|
||||
|
||||
Interface:
|
||||
Interface layer:
|
||||
|
||||
- MessageSequence: Provides the data format used for communication.
|
||||
- Ashmem: Provides methods related to anonymous shared memory objects.
|
||||
Cross-process communication functional interface: API capabilities for cross-process communication provided to developers, mainly including the following functions:
|
||||
|
||||
Framework:
|
||||
- Message sequence: During the RPC or IPC process, the sender can use the write methods provided by MessageSequence to write the data to be sent into the object in a specific format. The receiver can use the read methods provided by MessageSequence to read data in a specific format from the object. Data formats include: basic types and arrays, IPC objects, interface descriptors, and custom serialized objects.
|
||||
- Anonymous shared memory object: Provides methods related to anonymous shared memory objects, including creating, closing, mapping and unmapping Ashmem, reading data from Ashmem and writing data, obtaining Ashmem size, and setting Ashmem protection.
|
||||
|
||||
- MessageSequence wrapper: Implementation encapsulation of Cangjie MessageSequence, providing MessageSequence capabilities.
|
||||
- Ashmem wrapper: Implementation encapsulation of Cangjie Ashmem, providing Ashmem capabilities.
|
||||
Framework layer:
|
||||
|
||||
- Explanation of Dependencies in the Architecture Diagram:
|
||||
- Cross-process communication function encapsulation: Implementation encapsulation of Cangjie cross-process communication, providing message sequence and anonymous shared memory object capabilities.
|
||||
|
||||
- communication_ipc: Responsible for providing basic RPC functions, and encapsulating the C Language interface to provide Cangjie for interoperability.
|
||||
- cangjie_ark_interop: Responsible for providing Cangjie APILevel class definitions, which are used to annotate APIs, as well as providing the definition of BusinessException class that is thrown to users.
|
||||
- hiviewdfx_cangjie_wrapper: Responsible for providing logging interfaces, which are used to print logs at key points in the execution path.
|
||||
Explanation of dependent components introduced in the architecture diagram:
|
||||
|
||||
- IPC/RPC component: Responsible for providing basic RPC functions, encapsulating C language interfaces for Cangjie interoperability.
|
||||
- cangjie_ark_interop: Responsible for providing Cangjie annotation class definitions for API annotation, and providing BusinessException exception class definitions thrown to users.
|
||||
- hiviewdfx_cangjie_wrapper: Responsible for providing log interfaces for printing logs at critical paths.
|
||||
|
||||
## Directory Structure
|
||||
|
||||
The DSoftBus directory structure is as follows:
|
||||
The main code directory structure of distributed soft bus Cangjie is as follows:
|
||||
|
||||
|
||||
```
|
||||
foundation/communication/communication_cangjie_wrapper
|
||||
|
||||
+8
-9
@@ -2,7 +2,7 @@
|
||||
|
||||
## 简介
|
||||
|
||||
在OpenHarmnoy平台上,分布式软总线仓颉封装为开发者提供了使用仓颉语言进行应用开发时所需的跨进程通信相关的能力。当前开放的分布式软总线仓颉接口仅支持standard设备。
|
||||
在OpenHarmony平台上,分布式软总线仓颉封装为开发者提供了使用仓颉语言进行应用开发时所需的跨进程通信相关的能力。IPC(Inter-Process Communication)与RPC(Remote Procedure Call)机制用于实现跨进程通信,不同的是前者使用Binder驱动,用于设备内的跨进程通信,而后者使用软总线驱动,用于跨设备跨进程通信。IPC典型场景在后台服务,应用的后台服务通过IPC机制提供跨进程的服务调用能力,RPC典型使用场景在多端协同,多端协同通过RPC机制提供远端接口调用与数据传递能力。当前开放的分布式软总线仓颉接口仅支持standard设备。
|
||||
|
||||
## 系统架构
|
||||
|
||||
@@ -10,17 +10,16 @@
|
||||
|
||||

|
||||
|
||||
如架构图所示:
|
||||
|
||||
接口层:
|
||||
|
||||
- 消息序列:提供基础类型及数组、IPC对象、接口描述符和自定义序列化对象等用来通信的数据格式。
|
||||
进程间通信功能接口:面向开发者提供的进程间通信的API能力,主要包括以下功能:
|
||||
|
||||
- 消息序列:在RPC或IPC过程中,发送方可以使用MessageSequence提供的写方法,将待发送的数据以特定格式写入该对象。接收方可以使用MessageSequence提供的读方法从该对象中读取特定格式的数据。数据格式包括:基础类型及数组、IPC对象、接口描述符和自定义序列化对象。
|
||||
- 匿名共享内存对象:提供与匿名共享内存对象相关的方法,包括创建、关闭、映射和取消映射Ashmem、从Ashmem读取数据和写入数据、获取Ashmem大小、设置Ashmem保护。
|
||||
|
||||
框架层:
|
||||
|
||||
- 消息序列封装:仓颉消息序列的实现封装,提供消息序列能力。
|
||||
- 匿名共享内存对象封装:仓颉匿名共享内存对象的实现封装,提供匿名共享内存对象能力。
|
||||
- 进程间通信功能封装:仓颉进程间通信的实现封装,提供消息序列以及匿名共享内存对象的能力。
|
||||
|
||||
架构图中的依赖部件引入说明:
|
||||
|
||||
@@ -55,15 +54,15 @@ foundation/communication/communication_cangjie_wrapper
|
||||
RPC相关API请参见[RPC通信](https://gitcode.com/openharmony-sig/arkcompiler_cangjie_ark_interop/blob/master/doc/API_Reference/source_zh_cn/apis/IPCKit/cj-apis-rpc.md),相关指导请参见[RPC开发指南](https://gitcode.com/openharmony-sig/arkcompiler_cangjie_ark_interop/blob/master/doc/Dev_Guide/source_zh_cn/ipc/cj-ipc-rpc-overview.md)。
|
||||
|
||||
## 约束
|
||||
- 单个设备上跨进程通信时,传输的数据量最大约为1MB,过大的数据量请使用匿名共享内存。
|
||||
|
||||
与ArkTS提供的API能力相比:
|
||||
- 不支持把跨设备的Proxy对象传递回该Proxy对象所指向的Stub对象所在的设备。
|
||||
|
||||
- IPC暂不支持以下功能:
|
||||
- 与ArkTS提供的API能力相比,暂不支持以下功能:
|
||||
- 实现IRemoteObject代理对象。
|
||||
- 获取IPC上下文信息,包括获取UID和PID、获取本端和对端设备ID、检查接口调用是否在同一设备上。
|
||||
- 实现远程对象。
|
||||
|
||||
- 暂不支持蓝牙、WLAN功能。
|
||||
|
||||
## 参与贡献
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 29 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 68 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
Reference in New Issue
Block a user