文件名称:
Subscriber.md
所在目录:
Openharmony v1.0 / docs / api / api-SmartVision-Devices
文件大小:
11.21 KB
下载地址:
文本预览:
# Subscriber
## **Overview**
**Related Modules:**
[Broadcast](Broadcast.md)
**Description:**
Defines the subscriber for external interfaces to subsribe to events and data of a topic.
## **Summary**
## Data Fields
## **Details**
## **Field Documentation**
## AddTopic
```
int(* Subscriber::AddTopic) ([IUnknown](IUnknown.md) *iUnknown, const [Topic](Broadcast.md#gaf03f5bc94cad32ab628a6cdee09b0542) *topic)
```
**Description:**
Adds a specified topic to the Broadcast service.
The specified topic is added by the subscriber. A topic can be subscribed to only after being added.
**Parameters:**
**Returns:**
Returns **EC\_SUCCESS** if the topic is successfully added; returns other error codes if the topic fails to be added.
## ModifyConsumer
```
[Consumer](Consumer.md)*(* Subscriber::ModifyConsumer) ([IUnknown](IUnknown.md) *iUnknown, const [Topic](Broadcast.md#gaf03f5bc94cad32ab628a6cdee09b0542) *topic, [Consumer](Consumer.md) *old, [Consumer](Consumer.md) *current)
```
**Description:**
Modifies the consumer of a specified topic.
**Parameters:**
**Returns:**
Returns the pointer of the original consumer if the modification is successful; returns **NULL** otherwise.
## Subscribe
```
int(* Subscriber::Subscribe) ([IUnknown](IUnknown.md) *iUnknown, const [Topic](Broadcast.md#gaf03f5bc94cad32ab628a6cdee09b0542) *topic, [Consumer](Consumer.md) *consumer)
```
**Description:**
Subscribes to a specified topic for consumers.
Call this function on the subscriber. The topic to be subscribed to must have been added to the Broadcast service.
**Parameters:**
**Returns:**
Returns **EC\_SUCCESS** if the subscription is successful; returns other error codes if the subscription fails.
## Unsubscribe
```
[Consumer](Consumer.md)*(* Subscriber::Unsubscribe) ([IUnknown](IUnknown.md) *iUnknown, const [Topic](Broadcast.md#gaf03f5bc94cad32ab628a6cdee09b0542) *topic, const [Consumer](Consumer.md) *consumer)
```
**Description:**
Unsubscribes from a specified topic.
This function cancels the subscription relationship between the specified topic and consumer.
**Parameters:**
**Returns:**
Returns the pointer of the consumer if the unsubscription is successful; returns **NULL** otherwise.
## **Overview**
**Related Modules:**
[Broadcast](Broadcast.md)
**Description:**
Defines the subscriber for external interfaces to subsribe to events and data of a topic.
## **Summary**
## Data Fields
AddTopic )(IUnknown *iUnknown, const Topic *topic) | Adds a specified topic to the Broadcast service. |
Subscribe )(IUnknown *iUnknown, const Topic *topic, Consumer *consumer) | Subscribes to a specified topic for consumers. |
ModifyConsumer )(IUnknown *iUnknown, const Topic *topic, Consumer *old, Consumer *current) | Consumer *(* Modifies the consumer of a specified topic. |
Unsubscribe )(IUnknown *iUnknown, const Topic *topic, const Consumer *consumer) | Consumer *(* Unsubscribes from a specified topic. |
## **Details**
## **Field Documentation**
## AddTopic
```
int(* Subscriber::AddTopic) ([IUnknown](IUnknown.md) *iUnknown, const [Topic](Broadcast.md#gaf03f5bc94cad32ab628a6cdee09b0542) *topic)
```
**Description:**
Adds a specified topic to the Broadcast service.
The specified topic is added by the subscriber. A topic can be subscribed to only after being added.
**Parameters:**
iUnknown | Indicates external interface of the pub/sub feature. |
topic | Indicates the topic to be subscribed to. |
**Returns:**
Returns **EC\_SUCCESS** if the topic is successfully added; returns other error codes if the topic fails to be added.
## ModifyConsumer
```
[Consumer](Consumer.md)*(* Subscriber::ModifyConsumer) ([IUnknown](IUnknown.md) *iUnknown, const [Topic](Broadcast.md#gaf03f5bc94cad32ab628a6cdee09b0542) *topic, [Consumer](Consumer.md) *old, [Consumer](Consumer.md) *current)
```
**Description:**
Modifies the consumer of a specified topic.
**Parameters:**
iUnknown | Indicates the pointer to the external interface of the pub/sub feature. |
topic | Indicates the pointer to the topic whose consumer will be modified. |
old | Indicates the pointer to the original consumer of the topic. |
current | Indicates the pointer to the new consumer of the topic. |
**Returns:**
Returns the pointer of the original consumer if the modification is successful; returns **NULL** otherwise.
## Subscribe
```
int(* Subscriber::Subscribe) ([IUnknown](IUnknown.md) *iUnknown, const [Topic](Broadcast.md#gaf03f5bc94cad32ab628a6cdee09b0542) *topic, [Consumer](Consumer.md) *consumer)
```
**Description:**
Subscribes to a specified topic for consumers.
Call this function on the subscriber. The topic to be subscribed to must have been added to the Broadcast service.
**Parameters:**
iUnknown | Indicates external interface of the pub/sub feature. |
topic | Indicates the topic to be subscribed to. |
consumer | Indicates the consumer who subscribes to the topic. |
**Returns:**
Returns **EC\_SUCCESS** if the subscription is successful; returns other error codes if the subscription fails.
## Unsubscribe
```
[Consumer](Consumer.md)*(* Subscriber::Unsubscribe) ([IUnknown](IUnknown.md) *iUnknown, const [Topic](Broadcast.md#gaf03f5bc94cad32ab628a6cdee09b0542) *topic, const [Consumer](Consumer.md) *consumer)
```
**Description:**
Unsubscribes from a specified topic.
This function cancels the subscription relationship between the specified topic and consumer.
**Parameters:**
iUnknown | Indicates external interface of the pub/sub feature. This parameter is used to obtain subscription relationships. |
topic | Indicates the pointer to the topic to unsubscribe from. |
consumer | Indicates the pointer to the consumer. |
**Returns:**
Returns the pointer of the consumer if the unsubscription is successful; returns **NULL** otherwise.
点赞
回复
X