Merge branch 'release/2.2'

This commit is contained in:
MikaelMengistu 2018-10-16 14:39:02 -07:00
commit 83b5abbfcd
3 changed files with 13 additions and 4 deletions

View File

@ -24,7 +24,7 @@ public class Chat {
}, String.class, String.class);
hubConnection.onClosed((ex) -> {
if (ex.getMessage() != null) {
if (ex != null) {
System.out.printf("There was an error: %s", ex.getMessage());
}
});

View File

@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.SignalR
{
public class HubConnectionContext
{
private StreamTracker _streamTracker;
private static readonly Action<object> _cancelReader = state => ((PipeReader)state).CancelPendingRead();
private static readonly WaitCallback _abortedCallback = AbortConnection;
private readonly ConnectionContext _connectionContext;
@ -32,6 +32,7 @@ namespace Microsoft.AspNetCore.SignalR
private readonly long _clientTimeoutInterval;
private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1);
private StreamTracker _streamTracker;
private long _lastSendTimeStamp = DateTime.UtcNow.Ticks;
private long _lastReceivedTimeStamp = DateTime.UtcNow.Ticks;
private bool _receivedMessageThisInterval = false;
@ -356,7 +357,10 @@ namespace Microsoft.AspNetCore.SignalR
{
try
{
var input = Input;
using (var cts = new CancellationTokenSource())
using (var registration = cts.Token.Register(_cancelReader, input))
{
if (!Debugger.IsAttached)
{
@ -365,7 +369,8 @@ namespace Microsoft.AspNetCore.SignalR
while (true)
{
var result = await _connectionContext.Transport.Input.ReadAsync(cts.Token);
var result = await input.ReadAsync();
var buffer = result.Buffer;
var consumed = buffer.Start;
var examined = buffer.End;
@ -375,6 +380,7 @@ namespace Microsoft.AspNetCore.SignalR
if (result.IsCanceled)
{
Log.HandshakeCanceled(_logger);
await WriteHandshakeResponseAsync(new HandshakeResponseMessage("Handshake was canceled."));
return false;
}
@ -447,7 +453,7 @@ namespace Microsoft.AspNetCore.SignalR
}
finally
{
_connectionContext.Transport.Input.AdvanceTo(consumed, examined);
input.AdvanceTo(consumed, examined);
}
}
}

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.SignalR.Internal;
using Microsoft.Extensions.DependencyInjection.Extensions;
@ -36,6 +37,8 @@ namespace Microsoft.Extensions.DependencyInjection
public static ISignalRServerBuilder AddSignalR(this IServiceCollection services)
{
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.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<HubOptions>, HubOptionsSetup>());
return services.AddSignalRCore();