-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[SignalR] Pass new App to Transport Pipe to App layer #49650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
671f3d7
00d7ec0
ae53f44
b90cb5a
4520c67
3fb19b4
0859d33
685d24b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO.Pipelines; | ||
using System.Linq; | ||
#if NET8_0_OR_GREATER | ||
using System.Runtime.Versioning; | ||
#endif | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.AspNetCore.Connections.Abstractions; | ||
|
||
/// <summary> | ||
/// Provides access to connection reconnect operations. | ||
/// </summary> | ||
/// <remarks>This feature is experimental.</remarks> | ||
#if NET8_0_OR_GREATER | ||
[RequiresPreviewFeatures("IStatefulReconnectFeature is a preview interface")] | ||
#endif | ||
public interface IStatefulReconnectFeature | ||
{ | ||
/// <summary> | ||
/// Called when a connection reconnects. The new <see cref="PipeWriter"/> that application code should write to is passed in. | ||
/// </summary> | ||
public void OnReconnected(Func<PipeWriter, Task> notifyOnReconnect); | ||
|
||
/// <summary> | ||
/// Allows disabling the reconnect feature so a reconnecting connection will not be allowed anymore. | ||
/// </summary> | ||
void DisableReconnect(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -579,6 +579,13 @@ private async Task StopAsyncCore(bool disposing) | |
TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted, | ||
TaskScheduler.Default); | ||
} | ||
|
||
#pragma warning disable CA2252 // This API requires opting into preview features | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that if we do make API changes to preview features in 9.0, it could make things break harder when mixing 8.0 and 9.0 packages? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So like the following examples:
Yeah that does seem bad :/ |
||
if (connectionState.Connection.Features.Get<IStatefulReconnectFeature>() is IStatefulReconnectFeature feature) | ||
{ | ||
feature.DisableReconnect(); | ||
} | ||
#pragma warning restore CA2252 // This API requires opting into preview features | ||
} | ||
else | ||
{ | ||
|
@@ -1088,6 +1095,14 @@ private async Task SendWithLock(ConnectionState expectedConnectionState, HubMess | |
{ | ||
Log.ReceivedCloseWithError(_logger, close.Error); | ||
} | ||
|
||
#pragma warning disable CA2252 // This API requires opting into preview features | ||
if (connectionState.Connection.Features.Get<IStatefulReconnectFeature>() is IStatefulReconnectFeature feature) | ||
{ | ||
feature.DisableReconnect(); | ||
} | ||
#pragma warning restore CA2252 // This API requires opting into preview features | ||
|
||
return close; | ||
case PingMessage _: | ||
Log.ReceivedPing(_logger); | ||
|
@@ -1900,14 +1915,16 @@ public ConnectionState(ConnectionContext connection, HubConnection hubConnection | |
_logger = _hubConnection._logger; | ||
_hasInherentKeepAlive = connection.Features.Get<IConnectionInherentKeepAliveFeature>()?.HasInherentKeepAlive ?? false; | ||
|
||
if (Connection.Features.Get<IReconnectFeature>() is IReconnectFeature feature) | ||
#pragma warning disable CA2252 // This API requires opting into preview features | ||
if (Connection.Features.Get<IStatefulReconnectFeature>() is IStatefulReconnectFeature feature) | ||
{ | ||
_messageBuffer = new MessageBuffer(connection, hubConnection._protocol, | ||
_hubConnection._serviceProvider.GetService<IOptions<HubConnectionOptions>>()?.Value.StatefulReconnectBufferSize | ||
?? DefaultStatefulReconnectBufferSize); | ||
|
||
feature.NotifyOnReconnect = _messageBuffer.Resend; | ||
feature.OnReconnected(_messageBuffer.ResendAsync); | ||
} | ||
#pragma warning restore CA2252 // This API requires opting into preview features | ||
} | ||
|
||
public string GetNextId() => (++_nextInvocationId).ToString(CultureInfo.InvariantCulture); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.