|
8 | 8 | IClientReconnectOptions
|
9 | 9 | } from './client-options'
|
10 | 10 | import { Store } from './store'
|
11 |
| -import { Packet, QoS } from 'mqtt-packet' |
| 11 | +import { Packet, IConnectPacket, IPublishPacket, IDisconnectPacket, QoS } from 'mqtt-packet' |
12 | 12 |
|
13 | 13 | export interface ISubscriptionGrant {
|
14 | 14 | /**
|
@@ -66,9 +66,10 @@ export interface ISubscriptionMap {
|
66 | 66 | }
|
67 | 67 | }
|
68 | 68 |
|
69 |
| -export declare type OnConnectCallback = (packet: Packet) => void |
| 69 | +export declare type OnConnectCallback = (packet: IConnectPacket) => void |
| 70 | +export declare type OnDisconnectCallback = (packet: IDisconnectPacket) => void |
70 | 71 | export declare type ClientSubscribeCallback = (err: Error, granted: ISubscriptionGrant[]) => void
|
71 |
| -export declare type OnMessageCallback = (topic: string, payload: Buffer, packet: Packet) => void |
| 72 | +export declare type OnMessageCallback = (topic: string, payload: Buffer, packet: IPublishPacket) => void |
72 | 73 | export declare type OnPacketCallback = (packet: Packet) => void
|
73 | 74 | export declare type OnErrorCallback = (error: Error) => void
|
74 | 75 | export declare type PacketCallback = (error?: Error, packet?: Packet) => any
|
@@ -101,13 +102,19 @@ export declare class MqttClient extends events.EventEmitter {
|
101 | 102 | public on (event: 'connect', cb: OnConnectCallback): this
|
102 | 103 | public on (event: 'message', cb: OnMessageCallback): this
|
103 | 104 | public on (event: 'packetsend' | 'packetreceive', cb: OnPacketCallback): this
|
| 105 | + public on (event: 'disconnect', cb: OnDisconnectCallback): this |
104 | 106 | public on (event: 'error', cb: OnErrorCallback): this
|
| 107 | + public on (event: 'close', cb: OnCloseCallback): this |
| 108 | + public on (event: 'end' | 'reconnect' | 'offline' | 'outgoingEmpty', cb: () => void): this |
105 | 109 | public on (event: string, cb: Function): this
|
106 | 110 |
|
107 | 111 | public once (event: 'connect', cb: OnConnectCallback): this
|
108 | 112 | public once (event: 'message', cb: OnMessageCallback): this
|
109 | 113 | public once (event: 'packetsend' | 'packetreceive', cb: OnPacketCallback): this
|
| 114 | + public once (event: 'disconnect', cb: OnDisconnectCallback): this |
110 | 115 | public once (event: 'error', cb: OnErrorCallback): this
|
| 116 | + public once (event: 'close', cb: OnCloseCallback): this |
| 117 | + public once (event: 'end' | 'reconnect' | 'offline' | 'outgoingEmpty', cb: () => void): this |
111 | 118 | public once (event: string, cb: Function): this
|
112 | 119 |
|
113 | 120 | /**
|
|
0 commit comments