@@ -25,7 +25,6 @@ import {
2525 Payload ,
2626 MqttRequest ,
2727 MqttSubscribeRequest ,
28- MqttWill ,
2928 OnMessageCallback ,
3029 MqttConnectionConnected ,
3130 MqttConnectionDisconnected ,
@@ -36,12 +35,13 @@ import {
3635 OnConnectionFailedResult ,
3736 OnConnectionClosedResult
3837} from "../common/mqtt" ;
39- import { normalize_payload , normalize_payload_to_buffer } from "../common/mqtt_shared" ;
38+ import { normalize_payload , normalize_payload_to_buffer , MqttConnectionConfigBase } from "../common/mqtt_shared" ;
4039
4140export {
4241 QoS , Payload , MqttRequest , MqttSubscribeRequest , MqttWill , OnMessageCallback , MqttConnectionConnected , MqttConnectionDisconnected ,
4342 MqttConnectionResumed , OnConnectionSuccessResult , OnConnectionFailedResult , OnConnectionClosedResult
4443} from "../common/mqtt" ;
44+ export { MqttConnectionConfigBase } from "../common/mqtt_shared" ;
4545
4646/**
4747 * Listener signature for event emitted from an {@link MqttClientConnection} when an error occurs
@@ -110,88 +110,14 @@ export type AWSCredentials = auth.AWSCredentials;
110110/**
111111 * Configuration options for an MQTT connection
112112 *
113+ * Extends {@link MqttConnectionConfigBase} with browser-specific options.
114+ *
113115 * @category MQTT
114116 */
115- export interface MqttConnectionConfig {
116- /**
117- * ID to place in CONNECT packet. Must be unique across all devices/clients.
118- * If an ID is already in use, the other client will be disconnected.
119- */
120- client_id : string ;
121-
122- /** Server name to connect to */
123- host_name : string ;
124-
125- /** Server port to connect to */
126- port : number ;
127-
117+ export interface MqttConnectionConfig extends MqttConnectionConfigBase {
128118 /** Socket options, ignored in browser */
129119 socket_options : SocketOptions ;
130120
131- /**
132- * Whether or not to start a clean session with each reconnect.
133- * If True, the server will forget all subscriptions with each reconnect.
134- * Set False to request that the server resume an existing session
135- * or start a new session that may be resumed after a connection loss.
136- * The `session_present` bool in the connection callback informs
137- * whether an existing session was successfully resumed.
138- * If an existing session is resumed, the server remembers previous subscriptions
139- * and sends messages (with QoS1 or higher) that were published while the client was offline.
140- */
141- clean_session ?: boolean ;
142-
143- /**
144- * The keep alive value, in seconds, to send in CONNECT packet.
145- * A PING will automatically be sent at this interval.
146- * The server will assume the connection is lost if no PING is received after 1.5X this value.
147- * This duration must be longer than {@link ping_timeout}.
148- */
149- keep_alive ?: number ;
150-
151- /**
152- * Milliseconds to wait for ping response before client assumes
153- * the connection is invalid and attempts to reconnect.
154- * This duration must be shorter than keep_alive_secs.
155- * Alternatively, TCP keep-alive via :attr:`SocketOptions.keep_alive`
156- * may accomplish this in a more efficient (low-power) scenario,
157- * but keep-alive options may not work the same way on every platform and OS version.
158- */
159- ping_timeout ?: number ;
160-
161- /**
162- * Milliseconds to wait for the response to the operation requires response by protocol.
163- * Set to zero to disable timeout. Otherwise, the operation will fail if no response is
164- * received within this amount of time after the packet is written to the socket.
165- * It applied to PUBLISH (QoS>0) and UNSUBSCRIBE now.
166- */
167- protocol_operation_timeout ?: number ;
168-
169- /**
170- * Minimum seconds to wait between reconnect attempts.
171- * Must be <= {@link reconnect_max_sec}.
172- * Wait starts at min and doubles with each attempt until max is reached.
173- */
174- reconnect_min_sec ?: number ;
175-
176- /**
177- * Maximum seconds to wait between reconnect attempts.
178- * Must be >= {@link reconnect_min_sec}.
179- * Wait starts at min and doubles with each attempt until max is reached.
180- */
181- reconnect_max_sec ?: number ;
182-
183- /**
184- * Will to send with CONNECT packet. The will is
185- * published by the server when its connection to the client is unexpectedly lost.
186- */
187- will ?: MqttWill ;
188-
189- /** Username to connect with */
190- username ?: string ;
191-
192- /** Password to connect with */
193- password ?: string ;
194-
195121 /** Options for the underlying websocket connection */
196122 websocket ?: WebsocketOptions ;
197123
0 commit comments