Merge pull request #3163 from dotnet-maestro-bot/merge/release/2.2-to-master
[automated] Merge branch 'release/2.2' => 'master'
This commit is contained in:
commit
b5543a4d79
|
|
@ -9,28 +9,9 @@ resources:
|
|||
name: aspnet-BuildTools
|
||||
ref: refs/heads/master
|
||||
|
||||
phases:
|
||||
- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools
|
||||
jobs:
|
||||
- template: .azure/templates/project-ci.yml@buildtools
|
||||
parameters:
|
||||
agentOs: Windows
|
||||
beforeBuild:
|
||||
- task: NodeTool@0
|
||||
displayName: Use Node 8.x
|
||||
inputs:
|
||||
versionSpec: 8.x
|
||||
|
||||
- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools
|
||||
parameters:
|
||||
agentOs: macOS
|
||||
beforeBuild:
|
||||
- task: NodeTool@0
|
||||
displayName: Use Node 8.x
|
||||
inputs:
|
||||
versionSpec: 8.x
|
||||
|
||||
- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools
|
||||
parameters:
|
||||
agentOs: Linux
|
||||
beforeBuild:
|
||||
- task: NodeTool@0
|
||||
displayName: Use Node 8.x
|
||||
|
|
|
|||
|
|
@ -11,28 +11,9 @@ resources:
|
|||
name: aspnet/BuildTools
|
||||
ref: refs/heads/master
|
||||
|
||||
phases:
|
||||
- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools
|
||||
jobs:
|
||||
- template: .azure/templates/project-ci.yml@buildtools
|
||||
parameters:
|
||||
agentOs: Windows
|
||||
beforeBuild:
|
||||
- task: NodeTool@0
|
||||
displayName: Use Node 8.x
|
||||
inputs:
|
||||
versionSpec: 8.x
|
||||
|
||||
- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools
|
||||
parameters:
|
||||
agentOs: macOS
|
||||
beforeBuild:
|
||||
- task: NodeTool@0
|
||||
displayName: Use Node 8.x
|
||||
inputs:
|
||||
versionSpec: 8.x
|
||||
|
||||
- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools
|
||||
parameters:
|
||||
agentOs: Linux
|
||||
beforeBuild:
|
||||
- task: NodeTool@0
|
||||
displayName: Use Node 8.x
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ dependencies {
|
|||
testImplementation 'org.junit.jupiter:junit-jupiter-api'
|
||||
testCompile 'org.junit.jupiter:junit-jupiter-params'
|
||||
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
|
||||
testCompile 'org.slf4j:slf4j-jdk14:1.7.25'
|
||||
implementation 'com.google.code.gson:gson'
|
||||
implementation 'com.squareup.okhttp3:okhttp'
|
||||
implementation 'io.reactivex.rxjava2:rxjava'
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* A callback that takes no parameters.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Action {
|
||||
void invoke();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* A callback that takes one parameter.
|
||||
*
|
||||
* @param <T1> The type of the first parameter to the callback.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Action1<T1> {
|
||||
void invoke(T1 param1);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* A callback that takes two parameters.
|
||||
*
|
||||
* @param <T1> The type of the first parameter to the callback.
|
||||
* @param <T2> The type of the second parameter to the callback.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Action2<T1, T2> {
|
||||
void invoke(T1 param1, T2 param2);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,13 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* A callback that takes three parameters.
|
||||
*
|
||||
* @param <T1> The type of the first parameter to the callback.
|
||||
* @param <T2> The type of the second parameter to the callback.
|
||||
* @param <T3> The type of the third parameter to the callback.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Action3<T1, T2, T3> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,14 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* A callback that takes four parameters.
|
||||
*
|
||||
* @param <T1> The type of the first parameter to the callback.
|
||||
* @param <T2> The type of the second parameter to the callback.
|
||||
* @param <T3> The type of the third parameter to the callback.
|
||||
* @param <T4> The type of the fourth parameter to the callback.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Action4<T1, T2, T3, T4> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3, T4 param4);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,15 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* A callback that takes five parameter.
|
||||
*
|
||||
* @param <T1> The type of the first parameter to the callback.
|
||||
* @param <T2> The type of the second parameter to the callback.
|
||||
* @param <T3> The type of the third parameter to the callback.
|
||||
* @param <T4> The type of the fourth parameter to the callback.
|
||||
* @param <T5> The type of the fifth parameter to the callback.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Action5<T1, T2, T3, T4, T5> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3, T4 param4, T5 param5);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,16 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* A callback that takes six parameters.
|
||||
*
|
||||
* @param <T1> The type of the first parameter to the callback.
|
||||
* @param <T2> The type of the second parameter to the callback.
|
||||
* @param <T3> The type of the third parameter to the callback.
|
||||
* @param <T4> The type of the fourth parameter to the callback.
|
||||
* @param <T5> The type of the fifth parameter to the callback.
|
||||
* @param <T6> The type of the sixth parameter to the callback.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Action6<T1, T2, T3, T4, T5, T6> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,17 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* A callback that takes seven parameters.
|
||||
*
|
||||
* @param <T1> The type of the first parameter to the callback.
|
||||
* @param <T2> The type of the second parameter to the callback.
|
||||
* @param <T3> The type of the third parameter to the callback.
|
||||
* @param <T4> The type of the fourth parameter to the callback.
|
||||
* @param <T5> The type of the fifth parameter to the callback.
|
||||
* @param <T6> The type of the sixth parameter to the callback.
|
||||
* @param <T7> The type of the seventh parameter to the callback.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Action7<T1, T2, T3, T4, T5, T6, T7> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6, T7 param7);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,18 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* A callback that takes eight parameters.
|
||||
*
|
||||
* @param <T1> The type of the first parameter to the callback.
|
||||
* @param <T2> The type of the second parameter to the callback.
|
||||
* @param <T3> The type of the third parameter to the callback.
|
||||
* @param <T4> The type of the fourth parameter to the callback.
|
||||
* @param <T5> The type of the fifth parameter to the callback.
|
||||
* @param <T6> The type of the sixth parameter to the callback.
|
||||
* @param <T7> The type of the seventh parameter to the callback.
|
||||
* @param <T8> The type of the eighth parameter to the callback.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Action8<T1, T2, T3, T4, T5, T6, T7, T8> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6, T7 param7, T8 param8);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ import java.util.Map;
|
|||
|
||||
import io.reactivex.Single;
|
||||
|
||||
/**
|
||||
* A builder for configuring {@link HubConnection} instances.
|
||||
*/
|
||||
public class HttpHubConnectionBuilder {
|
||||
private final String url;
|
||||
private Transport transport;
|
||||
|
|
@ -22,36 +25,80 @@ public class HttpHubConnectionBuilder {
|
|||
this.url = url;
|
||||
}
|
||||
|
||||
public HttpHubConnectionBuilder withTransport(Transport transport) {
|
||||
/**
|
||||
* Sets the transport to be used by the {@link HubConnection}.
|
||||
*
|
||||
* @param transport The transport to be used.
|
||||
* @return This instance of the HttpHubConnectionBuilder.
|
||||
*/
|
||||
HttpHubConnectionBuilder withTransport(Transport transport) {
|
||||
this.transport = transport;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpHubConnectionBuilder withHttpClient(HttpClient httpClient) {
|
||||
/**
|
||||
* Sets the {@link HttpClient} to be used by the {@link HubConnection}.
|
||||
*
|
||||
* @param httpClient The {@link HttpClient} to be used by the {@link HubConnection}.
|
||||
* @return This instance of the HttpHubConnectionBuilder.
|
||||
*/
|
||||
HttpHubConnectionBuilder withHttpClient(HttpClient httpClient) {
|
||||
this.httpClient = httpClient;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates to the {@link HubConnection} that it should skip the negotiate process.
|
||||
* Note: This option only works with the Websockets transport and the Azure SignalR Service require the negotiate step.
|
||||
*
|
||||
* @param skipNegotiate Boolean indicating if the {@link HubConnection} should skip the negotiate step.
|
||||
* @return This instance of the HttpHubConnectionBuilder.
|
||||
*/
|
||||
public HttpHubConnectionBuilder shouldSkipNegotiate(boolean skipNegotiate) {
|
||||
this.skipNegotiate = skipNegotiate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the access token provider for the {@link HubConnection}.
|
||||
*
|
||||
* @param accessTokenProvider The access token provider to be used by the {@link HubConnection}.
|
||||
* @return This instance of the HttpHubConnectionBuilder.
|
||||
*/
|
||||
public HttpHubConnectionBuilder withAccessTokenProvider(Single<String> accessTokenProvider) {
|
||||
this.accessTokenProvider = accessTokenProvider;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the duration the {@link HubConnection} should wait for a Handshake Response from the server.
|
||||
*
|
||||
* @param timeout The duration that the {@link HubConnection} should wait for a Handshake Response from the server.
|
||||
* @return This instance of the HttpHubConnectionBuilder.
|
||||
*/
|
||||
public HttpHubConnectionBuilder withHandshakeResponseTimeout(Duration timeout) {
|
||||
this.handshakeResponseTimeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of Headers for the {@link HubConnection} to send with every Http request.
|
||||
*
|
||||
* @param headers A Map representing the collection of Headers that the {@link HubConnection} should send.
|
||||
* @return This instance of the HttpHubConnectionBuilder.
|
||||
*/
|
||||
public HttpHubConnectionBuilder withHeaders(Map<String, String> headers) {
|
||||
this.headers = headers;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a single header for the {@link HubConnection} to send.
|
||||
*
|
||||
* @param name The name of the header to set.
|
||||
* @param value The value of the header to be set.
|
||||
* @return This instance of the HttpHubConnectionBuilder.
|
||||
*/
|
||||
public HttpHubConnectionBuilder withHeader(String name, String value) {
|
||||
if (headers == null) {
|
||||
this.headers = new HashMap<>();
|
||||
|
|
@ -60,6 +107,11 @@ public class HttpHubConnectionBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a new instance of {@link HubConnection}.
|
||||
*
|
||||
* @return A new instance of {@link HubConnection}.
|
||||
*/
|
||||
public HubConnection build() {
|
||||
return new HubConnection(url, transport, skipNegotiate, httpClient, accessTokenProvider, handshakeResponseTimeout, headers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,18 +55,38 @@ public class HubConnection {
|
|||
private final Logger logger = LoggerFactory.getLogger(HubConnection.class);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the server timeout interval for the connection.
|
||||
*
|
||||
* @param serverTimeout The server timeout duration.
|
||||
*/
|
||||
public void setServerTimeout(Duration serverTimeout) {
|
||||
this.serverTimeout = serverTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server timeout duration.
|
||||
*
|
||||
* @return The server timeout duration.
|
||||
*/
|
||||
public Duration getServerTimeout() {
|
||||
return this.serverTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the keep alive interval duration.
|
||||
*
|
||||
* @param keepAliveInterval The interval at which the connection should send keep alive messages.
|
||||
*/
|
||||
public void setKeepAliveInterval(Duration keepAliveInterval) {
|
||||
this.keepAliveInterval = keepAliveInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the keep alive interval.
|
||||
*
|
||||
* @return The interval between keep alive messages.
|
||||
*/
|
||||
public Duration getKeepAliveInterval() {
|
||||
return this.keepAliveInterval;
|
||||
}
|
||||
|
|
@ -339,6 +359,7 @@ public class HubConnection {
|
|||
|
||||
/**
|
||||
* Stops a connection to the server.
|
||||
*
|
||||
* @param errorMessage An error message if the connected needs to be stopped because of an error.
|
||||
* @return A Completable that completes when the connection has been stopped.
|
||||
*/
|
||||
|
|
@ -364,6 +385,7 @@ public class HubConnection {
|
|||
|
||||
/**
|
||||
* Stops a connection to the server.
|
||||
*
|
||||
* @return A Completable that completes when the connection has been stopped.
|
||||
*/
|
||||
public Completable stop() {
|
||||
|
|
@ -416,6 +438,15 @@ public class HubConnection {
|
|||
sendHubMessage(invocationMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes a hub method on the server using the specified method name and arguments.
|
||||
*
|
||||
* @param returnType The expected return type.
|
||||
* @param method The name of the server method to invoke.
|
||||
* @param args The arguments used to invoke the server method.
|
||||
* @param <T> The expected return type.
|
||||
* @return A Single that yields the return value when the invocation has completed.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> Single<T> invoke(Class<T> returnType, String method, Object... args) {
|
||||
String id = connectionState.getNextInvocationId();
|
||||
|
|
@ -478,6 +509,11 @@ public class HubConnection {
|
|||
logger.trace("Removing handlers for client method: {}.", name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a callback to run when the connection is closed.
|
||||
*
|
||||
* @param callback A callback to run when the connection closes.
|
||||
*/
|
||||
public void onClosed(Consumer<Exception> callback) {
|
||||
if (onClosedCallbackList == null) {
|
||||
onClosedCallbackList = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,16 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* A builder for configuring {@link HubConnection} instances.
|
||||
*/
|
||||
public abstract class HubConnectionBuilder {
|
||||
/**
|
||||
* Creates a new instance of {@link HttpHubConnectionBuilder}.
|
||||
*
|
||||
* @param url The URL of the SignalR hub to connect to.
|
||||
* @return An instance of {@link HttpHubConnectionBuilder}.
|
||||
*/
|
||||
public static HttpHubConnectionBuilder create(String url) {
|
||||
if (url == null || url.isEmpty()) {
|
||||
throw new IllegalArgumentException("A valid url is required.");
|
||||
|
|
@ -11,5 +20,10 @@ public abstract class HubConnectionBuilder {
|
|||
return new HttpHubConnectionBuilder(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a new instance of {@link HubConnection}.
|
||||
*
|
||||
* @return A new instance of {@link HubConnection}.
|
||||
*/
|
||||
public abstract HubConnection build();
|
||||
}
|
||||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* Indicates the state of the {@link HubConnection}.
|
||||
*/
|
||||
public enum HubConnectionState {
|
||||
CONNECTED,
|
||||
DISCONNECTED,
|
||||
|
|
|
|||
|
|
@ -3,16 +3,34 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
/**
|
||||
* An exception thrown when the server fails to invoke a Hub method.
|
||||
*/
|
||||
public class HubException extends RuntimeException {
|
||||
private static final long serialVersionUID = -572019264269821519L;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the {@link HubException} class.
|
||||
*/
|
||||
public HubException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the {@link HubException} class with a specified error message.
|
||||
*
|
||||
* @param errorMessage The error message that explains the reason for the exception.
|
||||
*/
|
||||
public HubException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the {@link HubException} class with a specified error message and a reference
|
||||
* to the exception that is the cause of this exception.
|
||||
*
|
||||
* @param errorMessage The error message that explains the reason for the exception.
|
||||
* @param innerException The exception that is the cause of the current exception, or null if no inner exception is specified.
|
||||
*/
|
||||
public HubException(String errorMessage, Exception innerException) {
|
||||
super(errorMessage, innerException);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,17 +5,23 @@ package com.microsoft.signalr;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents the registration of a handler for a client method.
|
||||
*/
|
||||
public class Subscription {
|
||||
private final CallbackMap handlers;
|
||||
private final InvocationHandler handler;
|
||||
private final String target;
|
||||
|
||||
public Subscription(CallbackMap handlers, InvocationHandler handler, String target) {
|
||||
Subscription(CallbackMap handlers, InvocationHandler handler, String target) {
|
||||
this.handlers = handlers;
|
||||
this.handler = handler;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the client method handler represented by this subscription.
|
||||
*/
|
||||
public void unsubscribe() {
|
||||
List<InvocationHandler> handler = this.handlers.get(target);
|
||||
if (handler != null) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory(Skip= "https://github.com/aspnet/SignalR/issues/3058")]
|
||||
[ConditionalTheory]
|
||||
[SkipIfDockerNotPresent]
|
||||
[MemberData(nameof(TransportTypesAndProtocolTypes))]
|
||||
public async Task CanSendAndReceiveUserMessagesFromMultipleConnectionsWithSameUser(HttpTransportType transportType, string protocolName)
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
|
|||
.AddMessagePackProtocol()
|
||||
.AddRedis(options =>
|
||||
{
|
||||
// We start the servers before starting redis so we want to time them out ASAP
|
||||
options.Configuration.ConnectTimeout = 1;
|
||||
options.Configuration.EndPoints.Add(Environment.GetEnvironmentVariable("REDIS_CONNECTION-PREV"));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory(Skip= "https://github.com/aspnet/SignalR/issues/3058")]
|
||||
[ConditionalTheory]
|
||||
[SkipIfDockerNotPresent]
|
||||
[MemberData(nameof(TransportTypesAndProtocolTypes))]
|
||||
public async Task CanSendAndReceiveUserMessagesFromMultipleConnectionsWithSameUser(HttpTransportType transportType, string protocolName)
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests
|
|||
.AddMessagePackProtocol()
|
||||
.AddStackExchangeRedis(options =>
|
||||
{
|
||||
// We start the servers before starting redis so we want to time them out ASAP
|
||||
options.Configuration.ConnectTimeout = 1;
|
||||
options.Configuration.EndPoints.Add(Environment.GetEnvironmentVariable("REDIS_CONNECTION"));
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue