1717 */
1818package org .eclipse .paho .client .mqttv3 ;
1919
20+ import java .util .Map ;
2021import java .util .Properties ;
2122
2223import javax .net .SocketFactory ;
@@ -73,7 +74,8 @@ public class MqttConnectOptions {
7374 private int mqttVersion = MQTT_VERSION_DEFAULT ;
7475 private boolean automaticReconnect = false ;
7576 private int maxReconnectDelay = 128000 ;
76- private Properties customWebSocketHeaders = null ;
77+ private boolean skipPortDuringHandshake = false ;
78+ private Map <String , String > customWebSocketHeaders = null ;
7779
7880 // Client Operation Parameters
7981 private int executorServiceTimeout = 1 ; // How long to wait in seconds when terminating the executor service.
@@ -99,7 +101,7 @@ public MqttConnectOptions() {
99101
100102 /**
101103 * Returns the password to use for the connection.
102- *
104+ *
103105 * @return the password to use for the connection.
104106 */
105107 public char [] getPassword () {
@@ -108,7 +110,7 @@ public char[] getPassword() {
108110
109111 /**
110112 * Sets the password to use for the connection.
111- *
113+ *
112114 * @param password
113115 * A Char Array of the password
114116 */
@@ -118,7 +120,7 @@ public void setPassword(char[] password) {
118120
119121 /**
120122 * Returns the user name to use for the connection.
121- *
123+ *
122124 * @return the user name to use for the connection.
123125 */
124126 public String getUserName () {
@@ -127,7 +129,7 @@ public String getUserName() {
127129
128130 /**
129131 * Sets the user name to use for the connection.
130- *
132+ *
131133 * @param userName
132134 * The Username as a String
133135 */
@@ -137,7 +139,7 @@ public void setUserName(String userName) {
137139
138140 /**
139141 * Get the maximum time (in millis) to wait between reconnects
140- *
142+ *
141143 * @return Get the maximum time (in millis) to wait between reconnects
142144 */
143145 public int getMaxReconnectDelay () {
@@ -146,7 +148,7 @@ public int getMaxReconnectDelay() {
146148
147149 /**
148150 * Set the maximum time to wait between reconnects
149- *
151+ *
150152 * @param maxReconnectDelay
151153 * the duration (in millis)
152154 */
@@ -206,7 +208,7 @@ private void validateWill(String dest, Object payload) {
206208
207209 /**
208210 * Sets up the will information, based on the supplied parameters.
209- *
211+ *
210212 * @param topic
211213 * the topic to send the LWT message to
212214 * @param msg
@@ -227,7 +229,7 @@ protected void setWill(String topic, MqttMessage msg, int qos, boolean retained)
227229
228230 /**
229231 * Returns the "keep alive" interval.
230- *
232+ *
231233 * @see #setKeepAliveInterval(int)
232234 * @return the keep alive interval.
233235 */
@@ -237,7 +239,7 @@ public int getKeepAliveInterval() {
237239
238240 /**
239241 * Returns the MQTT version.
240- *
242+ *
241243 * @see #setMqttVersion(int)
242244 * @return the MQTT version.
243245 */
@@ -273,7 +275,7 @@ public void setKeepAliveInterval(int keepAliveInterval) throws IllegalArgumentEx
273275 /**
274276 * Returns the "max inflight". The max inflight limits to how many messages we
275277 * can send without receiving acknowledgments.
276- *
278+ *
277279 * @see #setMaxInflight(int)
278280 * @return the max inflight
279281 */
@@ -287,7 +289,7 @@ public int getMaxInflight() {
287289 * <p>
288290 * The default value is 10
289291 * </p>
290- *
292+ *
291293 * @param maxInflight
292294 * the number of maxInfligt messages
293295 */
@@ -300,7 +302,7 @@ public void setMaxInflight(int maxInflight) {
300302
301303 /**
302304 * Returns the connection timeout value.
303- *
305+ *
304306 * @see #setConnectionTimeout(int)
305307 * @return the connection timeout value.
306308 */
@@ -314,7 +316,7 @@ public int getConnectionTimeout() {
314316 * the MQTT server to be established. The default timeout is 30 seconds. A value
315317 * of 0 disables timeout processing meaning the client will wait until the
316318 * network connection is made successfully or fails.
317- *
319+ *
318320 * @param connectionTimeout
319321 * the timeout value, measured in seconds. It must be >0;
320322 */
@@ -328,7 +330,7 @@ public void setConnectionTimeout(int connectionTimeout) {
328330 /**
329331 * Returns the socket factory that will be used when connecting, or
330332 * <code>null</code> if one has not been set.
331- *
333+ *
332334 * @return The Socket Factory
333335 */
334336 public SocketFactory getSocketFactory () {
@@ -340,7 +342,7 @@ public SocketFactory getSocketFactory() {
340342 * apply its own policies around the creation of network sockets. If using an
341343 * SSL connection, an <code>SSLSocketFactory</code> can be used to supply
342344 * application-specific security settings.
343- *
345+ *
344346 * @param socketFactory
345347 * the factory to use.
346348 */
@@ -350,7 +352,7 @@ public void setSocketFactory(SocketFactory socketFactory) {
350352
351353 /**
352354 * Returns the topic to be used for last will and testament (LWT).
353- *
355+ *
354356 * @return the MqttTopic to use, or <code>null</code> if LWT is not set.
355357 * @see #setWill(MqttTopic, byte[], int, boolean)
356358 */
@@ -362,7 +364,7 @@ public String getWillDestination() {
362364 * Returns the message to be sent as last will and testament (LWT). The returned
363365 * object is "read only". Calling any "setter" methods on the returned object
364366 * will result in an <code>IllegalStateException</code> being thrown.
365- *
367+ *
366368 * @return the message to use, or <code>null</code> if LWT is not set.
367369 */
368370 public MqttMessage getWillMessage () {
@@ -371,7 +373,7 @@ public MqttMessage getWillMessage() {
371373
372374 /**
373375 * Returns the SSL properties for the connection.
374- *
376+ *
375377 * @return the properties for the SSL connection
376378 */
377379 public Properties getSSLProperties () {
@@ -447,7 +449,7 @@ public Properties getSSLProperties() {
447449 * object instead of using the default algorithm available in the platform.
448450 * Example values: "PKIX" or "IBMJ9X509".</dd>
449451 * </dl>
450- *
452+ *
451453 * @param props
452454 * The SSL {@link Properties}
453455 */
@@ -465,7 +467,7 @@ public void setHttpsHostnameVerificationEnabled(boolean httpsHostnameVerificatio
465467
466468 /**
467469 * Returns the HostnameVerifier for the SSL connection.
468- *
470+ *
469471 * @return the HostnameVerifier for the SSL connection
470472 */
471473 public HostnameVerifier getSSLHostnameVerifier () {
@@ -479,7 +481,7 @@ public HostnameVerifier getSSLHostnameVerifier() {
479481 * <p>
480482 * There is no default HostnameVerifier
481483 * </p>
482- *
484+ *
483485 * @param hostnameVerifier
484486 * the {@link HostnameVerifier}
485487 */
@@ -490,7 +492,7 @@ public void setSSLHostnameVerifier(HostnameVerifier hostnameVerifier) {
490492 /**
491493 * Returns whether the client and server should remember state for the client
492494 * across reconnects.
493- *
495+ *
494496 * @return the clean session flag
495497 */
496498 public boolean isCleanSession () {
@@ -517,7 +519,7 @@ public boolean isCleanSession() {
517519 * <li>The server will treat a subscription as non-durable
518520 * </ul>
519521 * </ul>
520- *
522+ *
521523 * @param cleanSession
522524 * Set to True to enable cleanSession
523525 */
@@ -527,7 +529,7 @@ public void setCleanSession(boolean cleanSession) {
527529
528530 /**
529531 * Return a list of serverURIs the client may connect to
530- *
532+ *
531533 * @return the serverURIs or null if not set
532534 */
533535 public String [] getServerURIs () {
@@ -580,7 +582,7 @@ public String[] getServerURIs() {
580582 * </p>
581583 * </li>
582584 * </ol>
583- *
585+ *
584586 * @param serverURIs
585587 * to be used by the client
586588 */
@@ -615,7 +617,7 @@ public void setMqttVersion(int mqttVersion) throws IllegalArgumentException {
615617 /**
616618 * Returns whether the client will automatically attempt to reconnect to the
617619 * server if the connection is lost
618- *
620+ *
619621 * @return the automatic reconnection flag.
620622 */
621623 public boolean isAutomaticReconnect () {
@@ -634,14 +636,14 @@ public boolean isAutomaticReconnect() {
634636 * double until it is at 2 minutes at which point the delay will stay at 2
635637 * minutes.</li>
636638 * </ul>
637- *
639+ *
638640 * @param automaticReconnect
639641 * If set to True, Automatic Reconnect will be enabled
640642 */
641643 public void setAutomaticReconnect (boolean automaticReconnect ) {
642644 this .automaticReconnect = automaticReconnect ;
643645 }
644-
646+
645647 public int getExecutorServiceTimeout () {
646648 return executorServiceTimeout ;
647649 }
@@ -650,13 +652,31 @@ public int getExecutorServiceTimeout() {
650652 * Set the time in seconds that the executor service should wait when
651653 * terminating before forcefully terminating. It is not recommended to change
652654 * this value unless you are absolutely sure that you need to.
653- *
655+ *
654656 * @param executorServiceTimeout the time in seconds to wait when shutting down.Ï
655657 */
656658 public void setExecutorServiceTimeout (int executorServiceTimeout ) {
657659 this .executorServiceTimeout = executorServiceTimeout ;
658660 }
659661
662+ /**
663+ * Returns whether to skip a port during a handshake
664+ *
665+ * @return skipPortDuringHandshake
666+ */
667+ public boolean isSkipPortDuringHandshake () {
668+ return skipPortDuringHandshake ;
669+ }
670+
671+ /**
672+ * Sets a flag that indicates whether to add a port to the host during a handshake
673+ *
674+ * @param skip if set to True, the port will not be added
675+ */
676+ public void setSkipPortDuringHandshake (boolean skip ) {
677+ this .skipPortDuringHandshake = skip ;
678+ }
679+
660680 /**
661681 * @return The Debug Properties
662682 */
@@ -679,26 +699,26 @@ public Properties getDebug() {
679699 } else {
680700 p .put ("SSLProperties" , getSSLProperties ());
681701 }
702+ p .put ("SkipPortDuringHandshake" , isSkipPortDuringHandshake ());
682703 return p ;
683704 }
684705
685706 /**
686707 * Sets the Custom WebSocket Headers for the WebSocket Connection.
687708 *
688- * @param props
689- * The custom websocket headers {@link Properties}
709+ * @param props The custom WebSocket headers
690710 */
691711
692- public void setCustomWebSocketHeaders (Properties props ) {
712+ public void setCustomWebSocketHeaders (Map < String , String > props ) {
693713 this .customWebSocketHeaders = props ;
694714 }
695715
696- public Properties getCustomWebSocketHeaders () {
716+ public Map < String , String > getCustomWebSocketHeaders () {
697717 return customWebSocketHeaders ;
698718 }
699719
700720 public String toString () {
701721 return Debug .dumpProperties (getDebug (), "Connection options" );
702722 }
703-
723+
704724}
0 commit comments