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