Skip to content

Commit a05868f

Browse files
committed
Add Protocol to HubConnection ctor
1 parent 90afb8f commit a05868f

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/HttpHubConnectionBuilder.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class HttpHubConnectionBuilder {
1616
private final String url;
1717
private Transport transport;
1818
private HttpClient httpClient;
19+
private HubProtocol protocol;
1920
private boolean skipNegotiate;
2021
private Single<String> accessTokenProvider;
2122
private long handshakeResponseTimeout = 0;
@@ -54,6 +55,17 @@ HttpHubConnectionBuilder withHttpClient(HttpClient httpClient) {
5455
this.httpClient = httpClient;
5556
return this;
5657
}
58+
59+
/**
60+
* Sets the {@link HubProtocol} to be used by the {@link HubConnection}.
61+
*
62+
* @param protocol The {@link HubProtocol} to be used by the {@link HubConnection}.
63+
* @return This instance of the HttpHubConnectionBuilder.
64+
*/
65+
HttpHubConnectionBuilder withProtocol(HubProtocol protocol) {
66+
this.protocol = protocol;
67+
return this;
68+
}
5769

5870
/**
5971
* Indicates to the {@link HubConnection} that it should skip the negotiate process.
@@ -133,7 +145,7 @@ public HttpHubConnectionBuilder setHttpClientBuilderCallback(Action1<OkHttpClien
133145
* @return A new instance of {@link HubConnection}.
134146
*/
135147
public HubConnection build() {
136-
return new HubConnection(url, transport, skipNegotiate, httpClient, accessTokenProvider,
148+
return new HubConnection(url, transport, skipNegotiate, httpClient, protocol, accessTokenProvider,
137149
handshakeResponseTimeout, headers, transportEnum, configureBuilder);
138150
}
139151
}

src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/HubConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ Transport getTransport() {
128128
return transport;
129129
}
130130

131-
HubConnection(String url, Transport transport, boolean skipNegotiate, HttpClient httpClient,
131+
HubConnection(String url, Transport transport, boolean skipNegotiate, HttpClient httpClient, HubProtocol protocol,
132132
Single<String> accessTokenProvider, long handshakeResponseTimeout, Map<String, String> headers, TransportEnum transportEnum,
133133
Action1<OkHttpClient.Builder> configureBuilder) {
134134
if (url == null || url.isEmpty()) {
135135
throw new IllegalArgumentException("A valid url is required.");
136136
}
137137

138138
this.baseUrl = url;
139-
this.protocol = new JsonHubProtocol();
139+
this.protocol = protocol;
140140

141141
if (accessTokenProvider != null) {
142142
this.accessTokenProvider = accessTokenProvider;

0 commit comments

Comments
 (0)