Merge branch 'release/2.2'
This commit is contained in:
commit
83b5abbfcd
|
|
@ -24,7 +24,7 @@ public class Chat {
|
||||||
}, String.class, String.class);
|
}, String.class, String.class);
|
||||||
|
|
||||||
hubConnection.onClosed((ex) -> {
|
hubConnection.onClosed((ex) -> {
|
||||||
if (ex.getMessage() != null) {
|
if (ex != null) {
|
||||||
System.out.printf("There was an error: %s", ex.getMessage());
|
System.out.printf("There was an error: %s", ex.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
{
|
{
|
||||||
public class HubConnectionContext
|
public class HubConnectionContext
|
||||||
{
|
{
|
||||||
private StreamTracker _streamTracker;
|
private static readonly Action<object> _cancelReader = state => ((PipeReader)state).CancelPendingRead();
|
||||||
private static readonly WaitCallback _abortedCallback = AbortConnection;
|
private static readonly WaitCallback _abortedCallback = AbortConnection;
|
||||||
|
|
||||||
private readonly ConnectionContext _connectionContext;
|
private readonly ConnectionContext _connectionContext;
|
||||||
|
|
@ -32,6 +32,7 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
private readonly long _clientTimeoutInterval;
|
private readonly long _clientTimeoutInterval;
|
||||||
private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1);
|
private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1);
|
||||||
|
|
||||||
|
private StreamTracker _streamTracker;
|
||||||
private long _lastSendTimeStamp = DateTime.UtcNow.Ticks;
|
private long _lastSendTimeStamp = DateTime.UtcNow.Ticks;
|
||||||
private long _lastReceivedTimeStamp = DateTime.UtcNow.Ticks;
|
private long _lastReceivedTimeStamp = DateTime.UtcNow.Ticks;
|
||||||
private bool _receivedMessageThisInterval = false;
|
private bool _receivedMessageThisInterval = false;
|
||||||
|
|
@ -356,7 +357,10 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var input = Input;
|
||||||
|
|
||||||
using (var cts = new CancellationTokenSource())
|
using (var cts = new CancellationTokenSource())
|
||||||
|
using (var registration = cts.Token.Register(_cancelReader, input))
|
||||||
{
|
{
|
||||||
if (!Debugger.IsAttached)
|
if (!Debugger.IsAttached)
|
||||||
{
|
{
|
||||||
|
|
@ -365,7 +369,8 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var result = await _connectionContext.Transport.Input.ReadAsync(cts.Token);
|
var result = await input.ReadAsync();
|
||||||
|
|
||||||
var buffer = result.Buffer;
|
var buffer = result.Buffer;
|
||||||
var consumed = buffer.Start;
|
var consumed = buffer.Start;
|
||||||
var examined = buffer.End;
|
var examined = buffer.End;
|
||||||
|
|
@ -375,6 +380,7 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
if (result.IsCanceled)
|
if (result.IsCanceled)
|
||||||
{
|
{
|
||||||
Log.HandshakeCanceled(_logger);
|
Log.HandshakeCanceled(_logger);
|
||||||
|
await WriteHandshakeResponseAsync(new HandshakeResponseMessage("Handshake was canceled."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -447,7 +453,7 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_connectionContext.Transport.Input.AdvanceTo(consumed, examined);
|
input.AdvanceTo(consumed, examined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Microsoft.AspNetCore.SignalR.Internal;
|
using Microsoft.AspNetCore.SignalR.Internal;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
|
@ -36,6 +37,8 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
public static ISignalRServerBuilder AddSignalR(this IServiceCollection services)
|
public static ISignalRServerBuilder AddSignalR(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddConnections();
|
services.AddConnections();
|
||||||
|
// Disable the WebSocket keep alive since SignalR has it's own
|
||||||
|
services.Configure<WebSocketOptions>(o => o.KeepAliveInterval = TimeSpan.Zero);
|
||||||
services.TryAddSingleton<SignalRMarkerService>();
|
services.TryAddSingleton<SignalRMarkerService>();
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<HubOptions>, HubOptionsSetup>());
|
services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<HubOptions>, HubOptionsSetup>());
|
||||||
return services.AddSignalRCore();
|
return services.AddSignalRCore();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue