@ray-js/wechat-mqtt 0.1.2-beta-2 → 0.1.3-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/index.d.ts +5 -0
- package/src/lib/auth.d.ts +3 -0
- package/src/lib/connect.d.ts +5 -0
- package/src/lib/constant.d.ts +6 -0
- package/src/lib/disconnect.d.ts +5 -0
- package/src/lib/factory.d.ts +11 -0
- package/src/lib/interface.d.ts +216 -0
- package/src/lib/packet.d.ts +22 -0
- package/src/lib/parse.d.ts +17 -0
- package/src/lib/ping.d.ts +3 -0
- package/src/lib/publish.d.ts +5 -0
- package/src/lib/subscribe.d.ts +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/wechat-mqtt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3-beta-1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@ray-js/wechat-helper": "^0.1.
|
|
29
|
-
"@ray-js/wechat-event": "^0.1.
|
|
28
|
+
"@ray-js/wechat-helper": "^0.1.3-beta-1",
|
|
29
|
+
"@ray-js/wechat-event": "^0.1.3-beta-1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {}
|
|
32
32
|
}
|
package/src/index.d.ts
CHANGED
package/src/lib/auth.d.ts
CHANGED
package/src/lib/connect.d.ts
CHANGED
package/src/lib/constant.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 控制报文类型
|
|
3
|
+
*/
|
|
1
4
|
export declare enum PacketType {
|
|
2
5
|
Reserved = 0,
|
|
3
6
|
CONNECT = 1,
|
|
@@ -16,6 +19,9 @@ export declare enum PacketType {
|
|
|
16
19
|
DISCONNECT = 14,
|
|
17
20
|
AUTH = 15
|
|
18
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* 属性标记
|
|
24
|
+
*/
|
|
19
25
|
export declare enum PropertySign {
|
|
20
26
|
sessionExpiryInterval = 17,
|
|
21
27
|
receiveMaximum = 33,
|
package/src/lib/disconnect.d.ts
CHANGED
package/src/lib/factory.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { Adapter, ClientConntroller, Options } from "./interface";
|
|
2
2
|
declare type Judge = () => boolean;
|
|
3
3
|
declare type Connect = (url: string, version?: number) => Promise<Adapter>;
|
|
4
|
+
/**
|
|
5
|
+
* 添加 Websocket 适配器
|
|
6
|
+
* 用于适配不同平台下 WebSocket
|
|
7
|
+
* @param judge 适配器是否生效判断
|
|
8
|
+
* @param creater 适配器生成函数
|
|
9
|
+
* @param priority 适配器是否优先,若为 true,则会优先尝试判断适配器
|
|
10
|
+
*/
|
|
4
11
|
export declare const addAdapter: (judge: Judge, creater: Connect, priority?: boolean) => void;
|
|
12
|
+
/**
|
|
13
|
+
* 创建适配器
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
5
16
|
export declare const createClient: (options: Options) => Promise<ClientConntroller>;
|
|
6
17
|
export {};
|
package/src/lib/interface.d.ts
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
export interface Adapter {
|
|
2
|
+
/**
|
|
3
|
+
* 关闭连接
|
|
4
|
+
*/
|
|
2
5
|
close: () => void;
|
|
6
|
+
/**
|
|
7
|
+
* 监听连接关闭
|
|
8
|
+
* @param cb
|
|
9
|
+
*/
|
|
3
10
|
onClose(cb: (ev: any) => void): void;
|
|
11
|
+
/**
|
|
12
|
+
* 发送消息
|
|
13
|
+
* @param data
|
|
14
|
+
*/
|
|
4
15
|
send(data: ArrayBuffer | ArrayBufferView): void;
|
|
16
|
+
/**
|
|
17
|
+
* 接收到消息监听
|
|
18
|
+
*/
|
|
5
19
|
onMessage(cb: (res: {
|
|
6
20
|
data: ArrayBuffer;
|
|
7
21
|
}) => void): void;
|
|
22
|
+
/**
|
|
23
|
+
* 网络连接成功
|
|
24
|
+
* @param cb
|
|
25
|
+
*/
|
|
8
26
|
onOpen(cb: (data: any) => void): void;
|
|
27
|
+
/**
|
|
28
|
+
* 连接出错
|
|
29
|
+
* @param cb
|
|
30
|
+
*/
|
|
9
31
|
onError(cb: (ev: any) => void): void;
|
|
10
32
|
}
|
|
11
33
|
export interface MQTTMessage {
|
|
@@ -13,46 +35,151 @@ export interface MQTTMessage {
|
|
|
13
35
|
payload: Uint8Array;
|
|
14
36
|
}
|
|
15
37
|
export interface ClientConntroller {
|
|
38
|
+
/**
|
|
39
|
+
* 配置
|
|
40
|
+
*/
|
|
16
41
|
options: Options;
|
|
42
|
+
/**
|
|
43
|
+
* 协议版本
|
|
44
|
+
*/
|
|
17
45
|
protocolVersion: number;
|
|
46
|
+
/**
|
|
47
|
+
* 服务端是否保存了会话
|
|
48
|
+
* 值为0|1
|
|
49
|
+
*/
|
|
18
50
|
sessionPresent: number;
|
|
19
51
|
connect(isReconnect?: boolean): Promise<any>;
|
|
20
52
|
isClose(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 是否在线
|
|
55
|
+
*/
|
|
21
56
|
isOnline(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 0 表示等待连接或连接中,1 为连接成功,2 为未连接
|
|
59
|
+
*/
|
|
22
60
|
getStatus(): 0 | 1 | 2;
|
|
61
|
+
/**
|
|
62
|
+
* 关闭连接
|
|
63
|
+
*/
|
|
23
64
|
close: () => void;
|
|
65
|
+
/**
|
|
66
|
+
* 监听连接关闭
|
|
67
|
+
* @param cb
|
|
68
|
+
*/
|
|
24
69
|
onClose(cb: (ev: any) => void): void;
|
|
70
|
+
/**
|
|
71
|
+
* 发送消息
|
|
72
|
+
* @param data
|
|
73
|
+
*/
|
|
25
74
|
send(data: ArrayBuffer | ArrayBufferView): void;
|
|
75
|
+
/**
|
|
76
|
+
* 连接出错
|
|
77
|
+
* @param cb
|
|
78
|
+
*/
|
|
26
79
|
onError(cb: (ev: any) => void): void;
|
|
80
|
+
/**
|
|
81
|
+
* 接收到消息监听
|
|
82
|
+
*/
|
|
27
83
|
onMessage(cb: (data: Uint8Array) => void): void;
|
|
28
84
|
offMessage(cb: (data: Uint8Array) => void): void;
|
|
29
85
|
offClose(cb: (ev: any) => void): void;
|
|
30
86
|
offError(cb: (ev: any) => void): void;
|
|
31
87
|
emitError(data: any): void;
|
|
88
|
+
/**
|
|
89
|
+
* mqtt 收到消息触发
|
|
90
|
+
* @param cb
|
|
91
|
+
*/
|
|
32
92
|
emitMqttMessage(data: MQTTMessage): void;
|
|
93
|
+
/**
|
|
94
|
+
* 注册 mqtt 收到消息事件
|
|
95
|
+
* @param cb
|
|
96
|
+
*/
|
|
33
97
|
onMqttMessage(cb: (data: MQTTMessage) => void): void;
|
|
98
|
+
/**
|
|
99
|
+
* 移除 mqtt 收到消息事件
|
|
100
|
+
* @param cb
|
|
101
|
+
*/
|
|
34
102
|
offMqttMessage(cb: (data: MQTTMessage) => void): void;
|
|
103
|
+
/**
|
|
104
|
+
* topic 别名处理
|
|
105
|
+
*/
|
|
35
106
|
applyTopic: (topicAlias: number, topicName: string) => void;
|
|
107
|
+
/**
|
|
108
|
+
* 通过别名获取 Topic
|
|
109
|
+
*/
|
|
36
110
|
getTopic: (topicAlias: number) => string;
|
|
111
|
+
/**
|
|
112
|
+
* 验证主题正确性
|
|
113
|
+
*/
|
|
37
114
|
checkTopic: (topicName: string) => boolean;
|
|
115
|
+
/**
|
|
116
|
+
* 加入主题
|
|
117
|
+
* @param topic
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
38
120
|
addTopic: (topic: string) => void;
|
|
121
|
+
/**
|
|
122
|
+
* 移除主题
|
|
123
|
+
* @param topic
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
39
126
|
removeTopic: (topic: string) => void;
|
|
127
|
+
/**
|
|
128
|
+
* 清除所有主题
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
40
131
|
clearTopic: () => void;
|
|
41
132
|
}
|
|
42
133
|
export declare type QoS = 0 | 1 | 2;
|
|
43
134
|
export declare type UserProperties = Record<string, string | string[]>;
|
|
44
135
|
export interface Options {
|
|
136
|
+
/**
|
|
137
|
+
* mqtt 连接地址
|
|
138
|
+
*/
|
|
45
139
|
url: string;
|
|
140
|
+
/**
|
|
141
|
+
* 账号
|
|
142
|
+
*/
|
|
46
143
|
username?: string;
|
|
144
|
+
/**
|
|
145
|
+
* 账号密码
|
|
146
|
+
*/
|
|
47
147
|
password?: string;
|
|
148
|
+
/**
|
|
149
|
+
* 客户端id
|
|
150
|
+
*/
|
|
48
151
|
clientId: string;
|
|
152
|
+
/**
|
|
153
|
+
* 协议版本
|
|
154
|
+
*/
|
|
49
155
|
protocolVersion?: number;
|
|
156
|
+
/**
|
|
157
|
+
* 心跳间隔时间
|
|
158
|
+
*/
|
|
50
159
|
keepalive?: number;
|
|
160
|
+
/**
|
|
161
|
+
* 是否为新会话
|
|
162
|
+
*/
|
|
51
163
|
clean?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* 遗嘱消息配置
|
|
166
|
+
*/
|
|
52
167
|
will?: {
|
|
168
|
+
/**
|
|
169
|
+
* 遗嘱主题
|
|
170
|
+
*/
|
|
53
171
|
topic: string;
|
|
172
|
+
/**
|
|
173
|
+
* 遗嘱数据
|
|
174
|
+
*/
|
|
54
175
|
payload: Uint8Array | string;
|
|
176
|
+
/**
|
|
177
|
+
* the QoS
|
|
178
|
+
*/
|
|
55
179
|
qos: QoS;
|
|
180
|
+
/**
|
|
181
|
+
* the retain flag
|
|
182
|
+
*/
|
|
56
183
|
retain: boolean;
|
|
57
184
|
properties?: {
|
|
58
185
|
willDelayInterval?: number;
|
|
@@ -64,6 +191,9 @@ export interface Options {
|
|
|
64
191
|
userProperties?: UserProperties;
|
|
65
192
|
};
|
|
66
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* 协议版本 5 properties
|
|
196
|
+
*/
|
|
67
197
|
properties?: {
|
|
68
198
|
sessionExpiryInterval?: number;
|
|
69
199
|
receiveMaximum?: number;
|
|
@@ -75,19 +205,55 @@ export interface Options {
|
|
|
75
205
|
authenticationMethod?: string;
|
|
76
206
|
authenticationData?: Uint8Array;
|
|
77
207
|
};
|
|
208
|
+
/**
|
|
209
|
+
*
|
|
210
|
+
* 连接超时时间
|
|
211
|
+
* 单位秒,默认 10 秒
|
|
212
|
+
*/
|
|
78
213
|
connectTimeout?: number;
|
|
214
|
+
/**
|
|
215
|
+
* 认证处理方法
|
|
216
|
+
* 在收到auth报文时触发
|
|
217
|
+
*/
|
|
79
218
|
onAuth?: (options: AuthOptions) => AuthOptions;
|
|
219
|
+
/**
|
|
220
|
+
* 当接收到消息且 qos 为 1 时的处理函数
|
|
221
|
+
* 如果不定义,则默认返回原因码 0
|
|
222
|
+
*/
|
|
80
223
|
onPuback?: (options: Message) => PuplishResponse;
|
|
224
|
+
/**
|
|
225
|
+
* 在收到 Pubrec 报文时用于返回 Pubrel 的处理函数,
|
|
226
|
+
* 如果不定义,则默认返回原因码 0
|
|
227
|
+
*
|
|
228
|
+
*/
|
|
81
229
|
onPubrel?: (options: PuplishResponse) => PuplishResponse;
|
|
230
|
+
/**
|
|
231
|
+
* 在收到 publish 报文时触发,用于返回 Pubrec 的处理函数
|
|
232
|
+
* 如果不定义,则默认返回原因码 0
|
|
233
|
+
*/
|
|
82
234
|
onPubrec?: (options: Message) => PuplishResponse;
|
|
235
|
+
/**
|
|
236
|
+
* 在接收到Pubrel时,用于处理 Pubcomp 返回
|
|
237
|
+
* 如果不定义,则默认返回原因码 0
|
|
238
|
+
*/
|
|
83
239
|
onPubcomp?: (options: PuplishResponse) => PuplishResponse;
|
|
84
240
|
}
|
|
85
241
|
export declare type QOS = 0 | 1 | 2;
|
|
86
242
|
export interface Message {
|
|
243
|
+
/**
|
|
244
|
+
* 消息标识
|
|
245
|
+
* qos > 0时必填
|
|
246
|
+
*/
|
|
87
247
|
id?: number;
|
|
88
248
|
dup?: boolean;
|
|
89
249
|
qos?: QOS;
|
|
250
|
+
/**
|
|
251
|
+
* 主题名
|
|
252
|
+
*/
|
|
90
253
|
topicName: string;
|
|
254
|
+
/**
|
|
255
|
+
* 协议5版本需要此值
|
|
256
|
+
*/
|
|
91
257
|
properties?: {
|
|
92
258
|
payloadFormatIndicator?: boolean;
|
|
93
259
|
messageExpiryInterval?: number;
|
|
@@ -115,7 +281,13 @@ export interface MessageOption {
|
|
|
115
281
|
};
|
|
116
282
|
}
|
|
117
283
|
export interface DisconnectOptions {
|
|
284
|
+
/**
|
|
285
|
+
* 原因码,默认为0
|
|
286
|
+
*/
|
|
118
287
|
reasonCode?: number;
|
|
288
|
+
/**
|
|
289
|
+
* 属性,协议版本5支持
|
|
290
|
+
*/
|
|
119
291
|
properties?: {
|
|
120
292
|
sessionExpiryInterval?: number;
|
|
121
293
|
reasonString?: string;
|
|
@@ -124,7 +296,13 @@ export interface DisconnectOptions {
|
|
|
124
296
|
};
|
|
125
297
|
}
|
|
126
298
|
export interface AuthOptions {
|
|
299
|
+
/**
|
|
300
|
+
* 原因码
|
|
301
|
+
*/
|
|
127
302
|
reasonCode: number;
|
|
303
|
+
/**
|
|
304
|
+
* 属性,协议版本5支持
|
|
305
|
+
*/
|
|
128
306
|
properties?: {
|
|
129
307
|
authenticationMethod: string;
|
|
130
308
|
authenticationData: string;
|
|
@@ -134,25 +312,63 @@ export interface AuthOptions {
|
|
|
134
312
|
}
|
|
135
313
|
export interface PuplishResponse {
|
|
136
314
|
id: number;
|
|
315
|
+
/**
|
|
316
|
+
* 原因码
|
|
317
|
+
*/
|
|
137
318
|
reasonCode?: number;
|
|
319
|
+
/**
|
|
320
|
+
* 属性,协议版本5支持
|
|
321
|
+
*/
|
|
138
322
|
properties?: {
|
|
139
323
|
reasonString?: string;
|
|
140
324
|
userProperties?: UserProperties;
|
|
141
325
|
};
|
|
142
326
|
}
|
|
143
327
|
export interface Client {
|
|
328
|
+
/**
|
|
329
|
+
* 0 表示等待连接或连接中,1 为连接成功,2 为未连接
|
|
330
|
+
*/
|
|
144
331
|
getStatus(): 0 | 1 | 2;
|
|
332
|
+
/**
|
|
333
|
+
* 接收消息监听
|
|
334
|
+
*/
|
|
145
335
|
onMessage(cb: (data: MQTTMessage) => void): void;
|
|
336
|
+
/**
|
|
337
|
+
* 取消接收消息监听
|
|
338
|
+
*/
|
|
146
339
|
offMessage(cb: (data: MQTTMessage) => void): void;
|
|
340
|
+
/**
|
|
341
|
+
* 发送消息
|
|
342
|
+
*/
|
|
147
343
|
publish(topic: string, message: string | Uint8Array, option?: MessageOption): void;
|
|
344
|
+
/**
|
|
345
|
+
* 重新认证
|
|
346
|
+
*/
|
|
148
347
|
reAuth(option: AuthOptions): void;
|
|
348
|
+
/**
|
|
349
|
+
* 断开连接
|
|
350
|
+
*/
|
|
149
351
|
disconnect(option?: DisconnectOptions): void;
|
|
352
|
+
/**
|
|
353
|
+
* 关闭事件
|
|
354
|
+
* @param cb
|
|
355
|
+
*/
|
|
150
356
|
onClose(cb: () => void): void;
|
|
357
|
+
/**
|
|
358
|
+
* 错误监听
|
|
359
|
+
* @param cb
|
|
360
|
+
*/
|
|
151
361
|
onError(cb: (e: any) => void): void;
|
|
362
|
+
/**
|
|
363
|
+
* 订阅
|
|
364
|
+
*/
|
|
152
365
|
subscribe: (topics: Topic[], options?: SubscribeOption) => Promise<{
|
|
153
366
|
err?: Record<string, number>;
|
|
154
367
|
properties?: any;
|
|
155
368
|
}>;
|
|
369
|
+
/**
|
|
370
|
+
* 取消订阅
|
|
371
|
+
*/
|
|
156
372
|
unsubscribe: (topic: string[], options?: UnsubscribeOption) => Promise<{
|
|
157
373
|
err?: Record<string, number>;
|
|
158
374
|
properties?: any;
|
package/src/lib/packet.d.ts
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import { PropertySign } from "./constant";
|
|
2
2
|
declare type WriteData = (data: string | number | number[] | Uint8Array) => void;
|
|
3
|
+
/**
|
|
4
|
+
* 创建数据包
|
|
5
|
+
* @param cmd 控制报文
|
|
6
|
+
* @param fixHeader 固定报文中,4个低字节位数值
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
3
9
|
export declare const createPacket: (cmd: number, fixHeader?: number) => {
|
|
4
10
|
header: (data: number | number[] | Uint8Array, needLen?: boolean, isVariable?: boolean) => void;
|
|
5
11
|
payload: (data: string | number | number[] | Uint8Array, needLen?: boolean, isVariable?: boolean) => void;
|
|
6
12
|
cleanCache(): void;
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param data
|
|
16
|
+
*/
|
|
7
17
|
cache: (data: string | number | number[] | Uint8Array, needLen?: boolean, isVariable?: boolean) => void;
|
|
8
18
|
putHeader(): void;
|
|
9
19
|
putPayload(): void;
|
|
10
20
|
getCache(): Uint8Array;
|
|
21
|
+
/**
|
|
22
|
+
* 获取 packet 数据
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
11
25
|
getPacket: () => Uint8Array;
|
|
12
26
|
};
|
|
13
27
|
export declare const writeString: (sign: PropertySign) => (v: string, write: WriteData) => void;
|
|
14
28
|
export declare const writePair: (sign: PropertySign) => (properies: Record<string, string | string[]>, write: WriteData) => void;
|
|
29
|
+
/**
|
|
30
|
+
* 属性值类型
|
|
31
|
+
*/
|
|
15
32
|
export declare const writeProperty: {
|
|
16
33
|
sessionExpiryInterval: (value: number, write: WriteData) => void;
|
|
17
34
|
receiveMaximum: (value: number, write: WriteData) => void;
|
|
@@ -31,5 +48,10 @@ export declare const writeProperty: {
|
|
|
31
48
|
correlationData: (value: Uint8Array, write: WriteData) => void;
|
|
32
49
|
subscriptionIdentifier: (value: number, write: WriteData) => void;
|
|
33
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* 转化 properties 的数据
|
|
53
|
+
* @param properies
|
|
54
|
+
* @param write
|
|
55
|
+
*/
|
|
34
56
|
export declare const packetProperties: (properies: any, write: WriteData) => void;
|
|
35
57
|
export {};
|
package/src/lib/parse.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { AuthOptions, ClientConntroller, Message, PuplishResponse } from "./interface";
|
|
2
|
+
/**
|
|
3
|
+
* 属性值类型
|
|
4
|
+
*/
|
|
2
5
|
export declare const parseProperty: {
|
|
3
6
|
sessionExpiryInterval: (data: Uint8Array, offset: number) => number[];
|
|
4
7
|
receiveMaximum: (data: Uint8Array, offset: number) => number[];
|
|
@@ -18,7 +21,21 @@ export declare const parseProperty: {
|
|
|
18
21
|
correlationData: (data: Uint8Array, offset: number) => [Uint8Array, number];
|
|
19
22
|
subscriptionIdentifier: (data: Uint8Array, offset: number) => number[];
|
|
20
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* 解析 properties
|
|
26
|
+
* @param data
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
21
29
|
export declare const parseProperties: (data: Uint8Array) => Record<string, any>;
|
|
30
|
+
/**
|
|
31
|
+
* 解析认证授权数据
|
|
32
|
+
* @param data
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
22
35
|
export declare const parseAuth: (data: Uint8Array) => AuthOptions;
|
|
36
|
+
/**
|
|
37
|
+
* 解析消息数据
|
|
38
|
+
* @param data
|
|
39
|
+
*/
|
|
23
40
|
export declare const parsePublish: (data: Uint8Array, client: ClientConntroller) => Message;
|
|
24
41
|
export declare const parsePublishResponse: (data: Uint8Array, client: ClientConntroller) => PuplishResponse;
|
package/src/lib/ping.d.ts
CHANGED
package/src/lib/publish.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { ClientConntroller, Message, PuplishResponse } from "./interface";
|
|
2
|
+
/**
|
|
3
|
+
* 发布消息
|
|
4
|
+
* @param client
|
|
5
|
+
* @param data
|
|
6
|
+
*/
|
|
2
7
|
export declare const publish: (client: ClientConntroller, message: Message) => Promise<void>;
|
|
3
8
|
export declare const puback: (client: ClientConntroller, message: PuplishResponse) => Promise<void>;
|
|
4
9
|
export declare const pubrel: (client: ClientConntroller, message: PuplishResponse) => Promise<void>;
|
package/src/lib/subscribe.d.ts
CHANGED
|
@@ -20,10 +20,18 @@ interface UnSubscribeOptions {
|
|
|
20
20
|
};
|
|
21
21
|
topics: string[];
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* 订阅消息
|
|
25
|
+
* @param client
|
|
26
|
+
* @param options
|
|
27
|
+
*/
|
|
23
28
|
export declare const subscribe: (client: ClientConntroller, options: SubscribeOptions) => Promise<{
|
|
24
29
|
reasonCode: Uint8Array;
|
|
25
30
|
properties?: any;
|
|
26
31
|
}>;
|
|
32
|
+
/**
|
|
33
|
+
* 取消订阅
|
|
34
|
+
*/
|
|
27
35
|
export declare const unsubscribe: (client: ClientConntroller, subscribe: UnSubscribeOptions) => Promise<{
|
|
28
36
|
reasonCode: Uint8Array;
|
|
29
37
|
properties?: any;
|