9
9
10
10
import io .reactivex .Single ;
11
11
12
+ /**
13
+ * A builder for configuring {@link HubConnection} instances.
14
+ */
12
15
public class HttpHubConnectionBuilder {
13
16
private final String url ;
14
17
private Transport transport ;
@@ -22,36 +25,80 @@ public class HttpHubConnectionBuilder {
22
25
this .url = url ;
23
26
}
24
27
25
- public HttpHubConnectionBuilder withTransport (Transport transport ) {
28
+ /**
29
+ * Sets the transport to be used by the {@link HubConnection}.
30
+ *
31
+ * @param transport The transport to be used.
32
+ * @return This instance of the HttpHubConnectionBuilder.
33
+ */
34
+ HttpHubConnectionBuilder withTransport (Transport transport ) {
26
35
this .transport = transport ;
27
36
return this ;
28
37
}
29
38
30
- public HttpHubConnectionBuilder withHttpClient (HttpClient httpClient ) {
39
+ /**
40
+ * Sets the {@link HttpClient} to be used by the {@link HubConnection}.
41
+ *
42
+ * @param httpClient The {@link HttpClient} to be used by the {@link HubConnection}.
43
+ * @return This instance of the HttpHubConnectionBuilder.
44
+ */
45
+ HttpHubConnectionBuilder withHttpClient (HttpClient httpClient ) {
31
46
this .httpClient = httpClient ;
32
47
return this ;
33
48
}
34
49
50
+ /**
51
+ * Indicates to the {@link HubConnection} that it should skip the negotiate process.
52
+ * Note: This option only works with the Websockets transport and the Azure SignalR Service require the negotiate step.
53
+ *
54
+ * @param skipNegotiate Boolean indicating if the {@link HubConnection} should skip the negotiate step.
55
+ * @return This instance of the HttpHubConnectionBuilder.
56
+ */
35
57
public HttpHubConnectionBuilder shouldSkipNegotiate (boolean skipNegotiate ) {
36
58
this .skipNegotiate = skipNegotiate ;
37
59
return this ;
38
60
}
39
61
62
+ /**
63
+ * Sets the access token provider for the {@link HubConnection}.
64
+ *
65
+ * @param accessTokenProvider The access token provider to be used by the {@link HubConnection}.
66
+ * @return This instance of the HttpHubConnectionBuilder.
67
+ */
40
68
public HttpHubConnectionBuilder withAccessTokenProvider (Single <String > accessTokenProvider ) {
41
69
this .accessTokenProvider = accessTokenProvider ;
42
70
return this ;
43
71
}
44
72
73
+ /**
74
+ * Sets the duration the {@link HubConnection} should wait for a Handshake Response from the server.
75
+ *
76
+ * @param timeout The duration that the {@link HubConnection} should wait for a Handshake Response from the server.
77
+ * @return This instance of the HttpHubConnectionBuilder.
78
+ */
45
79
public HttpHubConnectionBuilder withHandshakeResponseTimeout (Duration timeout ) {
46
80
this .handshakeResponseTimeout = timeout ;
47
81
return this ;
48
82
}
49
83
84
+ /**
85
+ * Sets a collection of Headers for the {@link HubConnection} to send with every Http request.
86
+ *
87
+ * @param headers A Map representing the collection of Headers that the {@link HubConnection} should send.
88
+ * @return This instance of the HttpHubConnectionBuilder.
89
+ */
50
90
public HttpHubConnectionBuilder withHeaders (Map <String , String > headers ) {
51
91
this .headers = headers ;
52
92
return this ;
53
93
}
54
94
95
+ /**
96
+ * Sets a single header for the {@link HubConnection} to send.
97
+ *
98
+ * @param name The name of the header to set.
99
+ * @param value The value of the header to be set.
100
+ * @return This instance of the HttpHubConnectionBuilder.
101
+ */
55
102
public HttpHubConnectionBuilder withHeader (String name , String value ) {
56
103
if (headers == null ) {
57
104
this .headers = new HashMap <>();
@@ -60,6 +107,11 @@ public HttpHubConnectionBuilder withHeader(String name, String value) {
60
107
return this ;
61
108
}
62
109
110
+ /**
111
+ * Builds a new instance of {@link HubConnection}.
112
+ *
113
+ * @return A new instance of {@link HubConnection}.
114
+ */
63
115
public HubConnection build () {
64
116
return new HubConnection (url , transport , skipNegotiate , httpClient , accessTokenProvider , handshakeResponseTimeout , headers );
65
117
}
0 commit comments