Ping Cleanup (#2530)

Tidied up some comments, to make the ResetPing client behavior easier to understand.

Will ping in debug mode for consistency. If this becomes a problem when debugging, developers can disable the pings manually. It's easier to fix something noisy, than try to diagnose inconsistently missing behavior.
This commit is contained in:
Dylan Dmitri Gray 2018-06-25 17:09:05 -07:00 committed by GitHub
parent c251e1768e
commit e7e2ca50e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -12,7 +12,6 @@ using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.SignalR.Client.Internal;
using Microsoft.AspNetCore.SignalR.Protocol;
@ -74,7 +73,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
/// Sending any message resets the timer to the start of the interval.
/// </remarks>
public TimeSpan KeepAliveInterval { get; set; } = DefaultKeepAliveInterval;
/// <summary>
/// Gets or sets the timeout for the initial handshake.
/// </summary>
@ -556,6 +555,9 @@ namespace Microsoft.AspNetCore.SignalR.Client
private async Task<(bool close, Exception exception)> ProcessMessagesAsync(HubMessage message, ConnectionState connectionState)
{
Log.ResettingKeepAliveTimer(_logger);
ResetTimeout();
InvocationRequest irq;
switch (message)
{
@ -601,7 +603,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
}
case PingMessage _:
Log.ReceivedPing(_logger);
// Nothing to do on receipt of a ping.
// timeout is reset above, on receiving any message
break;
default:
throw new InvalidOperationException($"Unexpected message type: {message.GetType().FullName}");
@ -777,9 +779,6 @@ namespace Microsoft.AspNetCore.SignalR.Client
}
else if (!buffer.IsEmpty)
{
Log.ResettingKeepAliveTimer(_logger);
ResetTimeout();
Log.ProcessingMessage(_logger, buffer.Length);
var close = false;

View File

@ -7,7 +7,6 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Pipelines;
using System.Runtime.ExceptionServices;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
@ -489,7 +488,7 @@ namespace Microsoft.AspNetCore.SignalR
Volatile.Write(ref _lastReceivedTimeStamp, DateTime.UtcNow.Ticks);
}
}
private static void AbortConnection(object state)
{
var connection = (HubConnectionContext)state;