rain
2024-04-01 35cb086a6e05bf0b6e2a6831330fbcd2c740eba7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.dji.sample.component.mqtt.service;
 
import com.dji.sample.component.mqtt.model.CommonTopicResponse;
import com.dji.sample.component.mqtt.model.ServiceReply;
import com.fasterxml.jackson.core.type.TypeReference;
 
/**
 * @author sean.zhou
 * @version 0.1
 * @date 2021/11/25
 */
public interface IMessageSenderService {
 
    /**
     * Publish a message to a specific topic.
     * @param topic target
     * @param response message
     */
    void publish(String topic, CommonTopicResponse response);
 
    /**
     * Use a specific qos to push messages to a specific topic.
     * @param topic target
     * @param qos   qos
     * @param response  message
     */
    void publish(String topic, int qos, CommonTopicResponse response);
 
    /**
     * Send message and receive a response at the same time.
     * 发送消息并同时接收响应。
     * @param clazz
     * @param topic
     * @param response  notification of whether the start is successful.
     * @return
     */
    <T> T publishWithReply(Class<T> clazz, String topic, CommonTopicResponse response);
 
    /**
     * Send message and receive a response at the same time.
     * @param clazz
     * @param topic
     * @param response
     * @param retryTime
     * @param <T>
     * @return
     */
    <T> T publishWithReply(Class<T> clazz, String topic, CommonTopicResponse response, int retryTime);
 
    /**
     * Used exclusively for sending messages for services.
     * @param clazz The generic class for ServiceReply.
     * @param sn
     * @param method
     * @param data
     * @param bid
     * @param <T>
     * @return
     */
    <T> ServiceReply<T> publishServicesTopic(TypeReference<T> clazz, String sn, String method, Object data, String bid);
 
    /**
     * Used exclusively for sending messages for services, and does not set the received subtype.
     * @param sn
     * @param method
     * @param data
     * @param bid
     * @return
     */
    ServiceReply publishServicesTopic(String sn, String method, Object data, String bid);
 
    /**
     * Used exclusively for sending messages for services.
     * @param clazz The generic class for ServiceReply.
     * @param sn
     * @param method
     * @param data
     * @param <T>
     * @return
     */
    <T> ServiceReply<T> publishServicesTopic(TypeReference<T> clazz, String sn, String method, Object data);
 
    /**
     * Used exclusively for sending messages for services, and does not set the received subtype.
     * @param sn
     * @param method
     * @param data
     * @return
     */
    ServiceReply publishServicesTopic(String sn, String method, Object data);
 
    <T> ServiceReply<T> publishRequestsTopic(TypeReference<T> clazz, String sn, String method, Object data, String bid);
 
    ServiceReply publishRequestsTopic(String sn, String method, Object data, String bid);
 
    ServiceReply publishRequestsTopic(String sn, String method, Object data);
 
}