Skip to content

Commit c39a8f9

Browse files
committedApr 6, 2021
MqttWebSocketConfig.serverPath -> path
MqttWebSocketConfig.queryString -> query DEFAULT_MQTT_SUBPROTOCOL -> DEFAULT_SUBPROTOCOL
1 parent f083af5 commit c39a8f9

File tree

6 files changed

+47
-48
lines changed

6 files changed

+47
-48
lines changed
 

‎src/main/java/com/hivemq/client2/internal/mqtt/MqttWebSocketConfigImpl.java

+15-16
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,33 @@
3030
public class MqttWebSocketConfigImpl implements MqttWebSocketConfig {
3131

3232
static final @NotNull MqttWebSocketConfigImpl DEFAULT =
33-
new MqttWebSocketConfigImpl(DEFAULT_SERVER_PATH, DEFAULT_QUERY_STRING, DEFAULT_MQTT_SUBPROTOCOL,
34-
DEFAULT_HANDSHAKE_TIMEOUT_MS);
33+
new MqttWebSocketConfigImpl(DEFAULT_PATH, DEFAULT_QUERY, DEFAULT_SUBPROTOCOL, DEFAULT_HANDSHAKE_TIMEOUT_MS);
3534

36-
private final @NotNull String serverPath;
37-
private final @NotNull String queryString;
35+
private final @NotNull String path;
36+
private final @NotNull String query;
3837
private final @NotNull String subprotocol;
3938
private final @Range(from = 0, to = Integer.MAX_VALUE) int handshakeTimeoutMs;
4039

4140
MqttWebSocketConfigImpl(
42-
final @NotNull String serverPath,
43-
final @NotNull String queryString,
41+
final @NotNull String path,
42+
final @NotNull String query,
4443
final @NotNull String subprotocol,
4544
final @Range(from = 0, to = Integer.MAX_VALUE) int handshakeTimeoutMs) {
4645

47-
this.serverPath = serverPath;
48-
this.queryString = queryString;
46+
this.path = path;
47+
this.query = query;
4948
this.subprotocol = subprotocol;
5049
this.handshakeTimeoutMs = handshakeTimeoutMs;
5150
}
5251

5352
@Override
54-
public @NotNull String getServerPath() {
55-
return serverPath;
53+
public @NotNull String getPath() {
54+
return path;
5655
}
5756

5857
@Override
59-
public @NotNull String getQueryString() {
60-
return queryString;
58+
public @NotNull String getQuery() {
59+
return query;
6160
}
6261

6362
@Override
@@ -85,14 +84,14 @@ public boolean equals(final @Nullable Object o) {
8584
}
8685
final MqttWebSocketConfigImpl that = (MqttWebSocketConfigImpl) o;
8786

88-
return serverPath.equals(that.serverPath) && queryString.equals(that.queryString) &&
89-
subprotocol.equals(that.subprotocol) && (handshakeTimeoutMs == that.handshakeTimeoutMs);
87+
return path.equals(that.path) && query.equals(that.query) && subprotocol.equals(that.subprotocol) &&
88+
(handshakeTimeoutMs == that.handshakeTimeoutMs);
9089
}
9190

9291
@Override
9392
public int hashCode() {
94-
int result = serverPath.hashCode();
95-
result = 31 * result + queryString.hashCode();
93+
int result = path.hashCode();
94+
result = 31 * result + query.hashCode();
9695
result = 31 * result + subprotocol.hashCode();
9796
result = 31 * result + Integer.hashCode(handshakeTimeoutMs);
9897
return result;

‎src/main/java/com/hivemq/client2/internal/mqtt/MqttWebSocketConfigImplBuilder.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,33 @@
3030
*/
3131
public abstract class MqttWebSocketConfigImplBuilder<B extends MqttWebSocketConfigImplBuilder<B>> {
3232

33-
private @NotNull String serverPath = MqttWebSocketConfigImpl.DEFAULT_SERVER_PATH;
34-
private @NotNull String queryString = MqttWebSocketConfigImpl.DEFAULT_QUERY_STRING;
35-
private @NotNull String subprotocol = MqttWebSocketConfigImpl.DEFAULT_MQTT_SUBPROTOCOL;
33+
private @NotNull String path = MqttWebSocketConfigImpl.DEFAULT_PATH;
34+
private @NotNull String query = MqttWebSocketConfigImpl.DEFAULT_QUERY;
35+
private @NotNull String subprotocol = MqttWebSocketConfigImpl.DEFAULT_SUBPROTOCOL;
3636
private @Range(from = 0, to = Integer.MAX_VALUE) int handshakeTimeoutMs =
3737
MqttWebSocketConfigImpl.DEFAULT_HANDSHAKE_TIMEOUT_MS;
3838

3939
MqttWebSocketConfigImplBuilder() {}
4040

4141
MqttWebSocketConfigImplBuilder(final @Nullable MqttWebSocketConfigImpl webSocketConfig) {
4242
if (webSocketConfig != null) {
43-
serverPath = webSocketConfig.getServerPath();
44-
queryString = webSocketConfig.getQueryString();
43+
path = webSocketConfig.getPath();
44+
query = webSocketConfig.getQuery();
4545
subprotocol = webSocketConfig.getSubprotocol();
4646
handshakeTimeoutMs = webSocketConfig.getHandshakeTimeoutMs();
4747
}
4848
}
4949

5050
abstract @NotNull B self();
5151

52-
public @NotNull B serverPath(final @Nullable String serverPath) {
52+
public @NotNull B path(final @Nullable String path) {
5353
// remove any leading slashes
54-
this.serverPath = Checks.notNull(serverPath, "Server path").replaceAll("^/+", "");
54+
this.path = Checks.notNull(path, "Server path").replaceAll("^/+", "");
5555
return self();
5656
}
5757

58-
public @NotNull B queryString(final @Nullable String queryString) {
59-
this.queryString = Checks.notNull(queryString, "Query string");
58+
public @NotNull B query(final @Nullable String query) {
59+
this.query = Checks.notNull(query, "Query string");
6060
return self();
6161
}
6262

@@ -73,7 +73,7 @@ public abstract class MqttWebSocketConfigImplBuilder<B extends MqttWebSocketConf
7373
}
7474

7575
public @NotNull MqttWebSocketConfigImpl build() {
76-
return new MqttWebSocketConfigImpl(serverPath, queryString, subprotocol, handshakeTimeoutMs);
76+
return new MqttWebSocketConfigImpl(path, query, subprotocol, handshakeTimeoutMs);
7777
}
7878

7979
public static class Default extends MqttWebSocketConfigImplBuilder<Default> implements MqttWebSocketConfigBuilder {

‎src/main/java/com/hivemq/client2/internal/mqtt/handler/websocket/MqttWebSocketInitializer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public void initChannel(
6464
final MqttTransportConfigImpl transportConfig = clientConfig.getCurrentTransportConfig();
6565
final InetSocketAddress serverAddress = transportConfig.getServerAddress();
6666
uri = new URI((transportConfig.getRawTlsConfig() == null) ? "ws" : "wss", null,
67-
serverAddress.getHostString(), serverAddress.getPort(), "/" + webSocketConfig.getServerPath(),
68-
webSocketConfig.getQueryString(), null);
67+
serverAddress.getHostString(), serverAddress.getPort(), "/" + webSocketConfig.getPath(),
68+
webSocketConfig.getQuery(), null);
6969
} catch (final URISyntaxException e) {
7070
onError.accept(channel, e);
7171
return;

‎src/main/java/com/hivemq/client2/mqtt/MqttWebSocketConfig.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@
3232
public interface MqttWebSocketConfig {
3333

3434
/**
35-
* The default WebSocket server path.
35+
* The default WebSocket path.
3636
*/
37-
@NotNull String DEFAULT_SERVER_PATH = "";
37+
@NotNull String DEFAULT_PATH = "";
3838
/**
39-
* The default WebSocket query string.
39+
* The default WebSocket query.
4040
*/
41-
@NotNull String DEFAULT_QUERY_STRING = "";
41+
@NotNull String DEFAULT_QUERY = "";
4242
/**
4343
* The default WebSocket subprotocol.
4444
* <p>
4545
* See the <a href="https://www.iana.org/assignments/websocket/websocket.xml#subprotocol-name">WebSocket Subprotocol
4646
* Name Registry</a>
4747
*/
48-
@NotNull String DEFAULT_MQTT_SUBPROTOCOL = "mqtt";
48+
@NotNull String DEFAULT_SUBPROTOCOL = "mqtt";
4949
/**
50-
* The default websocket handshake timeout in milliseconds.
50+
* The default WebSocket handshake timeout in milliseconds.
5151
*
5252
* @since 1.2
5353
*/
@@ -63,22 +63,22 @@ public interface MqttWebSocketConfig {
6363
}
6464

6565
/**
66-
* @return the WebSocket server path.
66+
* @return the WebSocket path.
6767
*/
68-
@NotNull String getServerPath();
68+
@NotNull String getPath();
6969

7070
/**
71-
* @return the WebSocket query string.
71+
* @return the WebSocket query.
7272
*/
73-
@NotNull String getQueryString();
73+
@NotNull String getQuery();
7474

7575
/**
7676
* @return the WebSocket subprotocol.
7777
*/
7878
@NotNull String getSubprotocol();
7979

8080
/**
81-
* @return the websocket handshake timeout in milliseconds.
81+
* @return the WebSocket handshake timeout in milliseconds.
8282
* @since 1.2
8383
*/
8484
@Range(from = 0, to = Integer.MAX_VALUE) int getHandshakeTimeoutMs();

‎src/main/java/com/hivemq/client2/mqtt/MqttWebSocketConfigBuilderBase.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@
3333
public interface MqttWebSocketConfigBuilderBase<B extends MqttWebSocketConfigBuilderBase<B>> {
3434

3535
/**
36-
* Sets the {@link MqttWebSocketConfig#getServerPath() server path}.
36+
* Sets the {@link MqttWebSocketConfig#getPath() path}.
3737
*
38-
* @param serverPath the server path.
38+
* @param path the path.
3939
* @return the builder.
4040
*/
4141
@CheckReturnValue
42-
@NotNull B serverPath(@NotNull String serverPath);
42+
@NotNull B path(@NotNull String path);
4343

4444
/**
45-
* Sets the {@link MqttWebSocketConfig#getQueryString() query string}.
45+
* Sets the {@link MqttWebSocketConfig#getQuery() query}.
4646
*
47-
* @param queryString the query string.
47+
* @param query the query.
4848
* @return the builder.
4949
*/
5050
@CheckReturnValue
51-
@NotNull B queryString(@NotNull String queryString);
51+
@NotNull B query(@NotNull String query);
5252

5353
/**
5454
* Sets the {@link MqttWebSocketConfig#getSubprotocol() subprotocol}.
@@ -60,11 +60,11 @@ public interface MqttWebSocketConfigBuilderBase<B extends MqttWebSocketConfigBui
6060
@NotNull B subprotocol(@NotNull String subprotocol);
6161

6262
/**
63-
* Sets the {@link MqttWebSocketConfig#getHandshakeTimeoutMs() websocket handshake timeout}.
63+
* Sets the {@link MqttWebSocketConfig#getHandshakeTimeoutMs() WebSocket handshake timeout}.
6464
* <p>
6565
* The timeout in milliseconds must be in the range: [0, {@link Integer#MAX_VALUE}].
6666
*
67-
* @param timeout the websocket handshake timeout or <code>0</code> to disable the timeout.
67+
* @param timeout the WebSocket handshake timeout or <code>0</code> to disable the timeout.
6868
* @param timeUnit the time unit of the given timeout (this timeout only supports millisecond precision).
6969
* @return the builder.
7070
* @since 1.2

‎src/test/java/com/hivemq/client2/example/Mqtt3ClientExample.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private Mqtt3RxClient getClient() {
175175
}
176176

177177
if (isNotUsingMqttPort(port)) {
178-
mqttClientBuilder.webSocketConfig(MqttWebSocketConfig.builder().serverPath(serverPath).build());
178+
mqttClientBuilder.webSocketConfig(MqttWebSocketConfig.builder().path(serverPath).build());
179179
}
180180

181181
return mqttClientBuilder.useMqttVersion3().buildRx();

0 commit comments

Comments
 (0)
Failed to load comments.