Skip to content

Commit b70b7ef

Browse files
committed
Merge in 'release/8.0-rc1' changes
2 parents 3ddcd4d + 7d80971 commit b70b7ef

24 files changed

+66
-60
lines changed

src/Servers/Kestrel/Core/src/ListenOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core;
1616
/// </summary>
1717
public class ListenOptions : IConnectionBuilder, IMultiplexedConnectionBuilder
1818
{
19-
internal const HttpProtocols DefaultHttpProtocols = HttpProtocols.Http1AndHttp2AndHttp3;
19+
internal const HttpProtocols DefaultHttpProtocols = HttpProtocols.Http1AndHttp2;
2020

2121
private readonly List<Func<ConnectionDelegate, ConnectionDelegate>> _middleware = new List<Func<ConnectionDelegate, ConnectionDelegate>>();
2222
private readonly List<Func<MultiplexedConnectionDelegate, MultiplexedConnectionDelegate>> _multiplexedMiddleware = new List<Func<MultiplexedConnectionDelegate, MultiplexedConnectionDelegate>>();

src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,7 @@ public ConnectionState(ConnectionContext connection, HubConnection hubConnection
19041904
{
19051905
_messageBuffer = new MessageBuffer(connection, hubConnection._protocol,
19061906
_hubConnection._serviceProvider.GetService<IOptions<HubConnectionOptions>>()?.Value.StatefulReconnectBufferSize
1907-
?? DefaultStatefulReconnectBufferSize);
1907+
?? DefaultStatefulReconnectBufferSize);
19081908

19091909
feature.NotifyOnReconnect = _messageBuffer.Resend;
19101910
}

src/SignalR/clients/csharp/Client/src/HubConnectionBuilderHttpExtensions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ namespace Microsoft.AspNetCore.SignalR.Client;
1919
/// </summary>
2020
public static class HubConnectionBuilderHttpExtensions
2121
{
22+
/// <summary>
23+
/// Configures the <see cref="HttpConnectionOptions"/> to negotiate stateful reconnect with the server.
24+
/// </summary>
25+
/// <param name="hubConnectionBuilder">The <see cref="IHubConnectionBuilder" /> to configure.</param>
26+
/// <returns>The same instance of the <see cref="IHubConnectionBuilder"/> for chaining.</returns>
27+
public static IHubConnectionBuilder WithStatefulReconnect(this IHubConnectionBuilder hubConnectionBuilder)
28+
{
29+
hubConnectionBuilder.Services.Configure<HttpConnectionOptions>(options => options.UseStatefulReconnect = true);
30+
31+
return hubConnectionBuilder;
32+
}
33+
2234
/// <summary>
2335
/// Configures the <see cref="HubConnection" /> to use HTTP-based transports to connect to the specified URL.
2436
/// </summary>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
#nullable enable
2+
static Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilderHttpExtensions.WithStatefulReconnect(this Microsoft.AspNetCore.SignalR.Client.IHubConnectionBuilder! hubConnectionBuilder) -> Microsoft.AspNetCore.SignalR.Client.IHubConnectionBuilder!

src/SignalR/clients/csharp/Client/test/FunctionalTests/HubConnectionTests.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,7 +2560,7 @@ public async Task CanReconnectAndSendMessageWhileDisconnected()
25602560
tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
25612561
return websocket;
25622562
};
2563-
o.UseAcks = true;
2563+
o.UseStatefulReconnect = true;
25642564
});
25652565
connectionBuilder.Services.AddSingleton(protocol);
25662566
var connection = connectionBuilder.Build();
@@ -2617,7 +2617,7 @@ public async Task CanReconnectAndSendMessageOnceConnected()
26172617
tcs.SetResult();
26182618
return websocket;
26192619
};
2620-
o.UseAcks = true;
2620+
o.UseStatefulReconnect = true;
26212621
})
26222622
.WithAutomaticReconnect();
26232623
connectionBuilder.Services.AddSingleton(protocol);
@@ -2691,8 +2691,8 @@ public async Task ChangingUserNameDuringReconnectLogsWarning()
26912691
tcs.SetResult();
26922692
return websocket;
26932693
};
2694-
o.UseAcks = true;
26952694
})
2695+
.WithStatefulReconnect()
26962696
.WithAutomaticReconnect();
26972697
connectionBuilder.Services.AddSingleton(protocol);
26982698
var connection = connectionBuilder.Build();
@@ -2756,7 +2756,7 @@ public async Task ServerAbortsConnectionWithAckingEnabledNoReconnectAttempted()
27562756
await ws.ConnectAsync(context.Uri, token);
27572757
return ws;
27582758
};
2759-
o.UseAcks = true;
2759+
o.UseStatefulReconnect = true;
27602760
});
27612761
connectionBuilder.Services.AddSingleton(protocol);
27622762
var connection = connectionBuilder.Build();
@@ -2799,12 +2799,10 @@ public async Task CanSetMessageBufferSizeOnClient()
27992799
const string originalMessage = "SignalR";
28002800
var connectionBuilder = new HubConnectionBuilder()
28012801
.WithLoggerFactory(LoggerFactory)
2802-
.WithUrl(server.Url + "/default", HttpTransportType.WebSockets, o =>
2803-
{
2804-
o.UseAcks = true;
2805-
});
2806-
connectionBuilder.Services.Configure<HubConnectionOptions>(o => o.StatefulReconnectBufferSize = 500);
2802+
.WithStatefulReconnect()
2803+
.WithUrl(server.Url + "/default", HttpTransportType.WebSockets);
28072804
connectionBuilder.Services.AddSingleton(protocol);
2805+
connectionBuilder.Services.Configure<HubConnectionOptions>(o => o.StatefulReconnectBufferSize = 500);
28082806
var connection = connectionBuilder.Build();
28092807

28102808
try

src/SignalR/clients/csharp/Client/test/FunctionalTests/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void Configure(IApplicationBuilder app)
9393

9494
app.UseEndpoints(endpoints =>
9595
{
96-
endpoints.MapHub<TestHub>("/default", o => o.AllowAcks = true);
96+
endpoints.MapHub<TestHub>("/default", o => o.AllowStatefulReconnects = true);
9797
endpoints.MapHub<DynamicTestHub>("/dynamic");
9898
endpoints.MapHub<TestHubT>("/hubT");
9999
endpoints.MapHub<HubWithAuthorization>("/authorizedhub");

src/SignalR/clients/csharp/Client/test/UnitTests/HttpConnectionFactoryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void ShallowCopyHttpConnectionOptionsCopiesAllPublicProperties()
100100
{ $"{nameof(HttpConnectionOptions.WebSocketFactory)}", webSocketFactory },
101101
{ $"{nameof(HttpConnectionOptions.ApplicationMaxBufferSize)}", 1L * 1024 * 1024 },
102102
{ $"{nameof(HttpConnectionOptions.TransportMaxBufferSize)}", 1L * 1024 * 1024 },
103-
{ $"{nameof(HttpConnectionOptions.UseAcks)}", true },
103+
{ $"{nameof(HttpConnectionOptions.UseStatefulReconnect)}", true },
104104
};
105105

106106
var options = new HttpConnectionOptions();

src/SignalR/clients/csharp/Http.Connections.Client/src/HttpConnection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,13 @@ private async Task SelectAndStartTransport(TransferFormat transferFormat, Cancel
399399
if (negotiationResponse == null)
400400
{
401401
// Temporary until other transports work
402-
_httpConnectionOptions.UseAcks = transportType == HttpTransportType.WebSockets ? _httpConnectionOptions.UseAcks : false;
402+
_httpConnectionOptions.UseStatefulReconnect = transportType == HttpTransportType.WebSockets ? _httpConnectionOptions.UseStatefulReconnect : false;
403403
negotiationResponse = await GetNegotiationResponseAsync(uri, cancellationToken).ConfigureAwait(false);
404404
connectUrl = CreateConnectUrl(uri, negotiationResponse.ConnectionToken);
405405
}
406406

407407
Log.StartingTransport(_logger, transportType, uri);
408-
await StartTransport(connectUrl, transportType, transferFormat, cancellationToken, negotiationResponse.UseAcking).ConfigureAwait(false);
408+
await StartTransport(connectUrl, transportType, transferFormat, cancellationToken, negotiationResponse.UseStatefulReconnect).ConfigureAwait(false);
409409
break;
410410
}
411411
}
@@ -457,7 +457,7 @@ private async Task<NegotiationResponse> NegotiateAsync(Uri url, HttpClient httpC
457457
uri = Utils.AppendQueryString(urlBuilder.Uri, $"negotiateVersion={_protocolVersionNumber}");
458458
}
459459

460-
if (_httpConnectionOptions.UseAcks)
460+
if (_httpConnectionOptions.UseStatefulReconnect)
461461
{
462462
uri = Utils.AppendQueryString(uri, "useAck=true");
463463
}

src/SignalR/clients/csharp/Http.Connections.Client/src/HttpConnectionFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal static HttpConnectionOptions ShallowCopyHttpConnectionOptions(HttpConne
8989
DefaultTransferFormat = options.DefaultTransferFormat,
9090
ApplicationMaxBufferSize = options.ApplicationMaxBufferSize,
9191
TransportMaxBufferSize = options.TransportMaxBufferSize,
92-
UseAcks = options.UseAcks,
92+
UseStatefulReconnect = options.UseStatefulReconnect,
9393
};
9494

9595
if (!OperatingSystem.IsBrowser())

src/SignalR/clients/csharp/Http.Connections.Client/src/HttpConnectionOptions.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,13 @@ public Action<ClientWebSocketOptions>? WebSocketConfiguration
276276
}
277277

278278
/// <summary>
279-
/// Setting to enable acking bytes sent between client and server, this allows reconnecting that preserves messages sent while disconnected.
279+
/// Setting to enable Stateful Reconnect between client and server, this allows reconnecting that preserves messages sent while disconnected.
280280
/// Also preserves the <see cref="HttpConnection.ConnectionId"/> when the reconnect is successful.
281281
/// </summary>
282282
/// <remarks>
283283
/// Only works with WebSockets transport currently.
284-
/// API likely to change in future previews.
285284
/// </remarks>
286-
public bool UseAcks { get; set; }
285+
public bool UseStatefulReconnect { get; set; }
287286

288287
private static void ThrowIfUnsupportedPlatform()
289288
{

0 commit comments

Comments
 (0)