Add nullable annotations to SignalR.Common, SignalR.Core and Http.Connections (#24764)
* Add nullable annotations to SignalR.Common, SignalR.Core and Http.Connections Contributes to https://github.com/dotnet/aspnetcore/issues/5680 * Changes per PR comments. Also add nullability to hub protocols
This commit is contained in:
parent
9408ed888d
commit
1867750ec9
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Connections
|
|||
/// <summary>
|
||||
/// Gets or sets a unique identifier to represent this connection in trace logs.
|
||||
/// </summary>
|
||||
public abstract string? ConnectionId { get; set; }
|
||||
public abstract string ConnectionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of features provided by the server and middleware available on this connection.
|
||||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Connections
|
|||
/// <summary>
|
||||
/// Gets or sets a key/value collection that can be used to share data within the scope of this connection.
|
||||
/// </summary>
|
||||
public abstract IDictionary<object, object?>? Items { get; set; }
|
||||
public abstract IDictionary<object, object?> Items { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when the client connection is closed.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Connections
|
|||
/// <summary>
|
||||
/// Gets or sets the <see cref="IDuplexPipe"/> that can be used to read or write data on this connection.
|
||||
/// </summary>
|
||||
public abstract IDuplexPipe? Transport { get; set; }
|
||||
public abstract IDuplexPipe Transport { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Aborts the underlying connection.
|
||||
|
|
|
|||
|
|
@ -55,17 +55,17 @@ namespace Microsoft.AspNetCore.Connections
|
|||
Application = application;
|
||||
}
|
||||
|
||||
public override string? ConnectionId { get; set; }
|
||||
public override string ConnectionId { get; set; }
|
||||
|
||||
public override IFeatureCollection Features { get; }
|
||||
|
||||
public ClaimsPrincipal? User { get; set; }
|
||||
|
||||
public override IDictionary<object, object?>? Items { get; set; } = new ConnectionItems();
|
||||
public override IDictionary<object, object?> Items { get; set; } = new ConnectionItems();
|
||||
|
||||
public IDuplexPipe? Application { get; set; }
|
||||
|
||||
public override IDuplexPipe? Transport { get; set; }
|
||||
public override IDuplexPipe Transport { get; set; } = default!;
|
||||
|
||||
public override CancellationToken ConnectionClosed { get; set; }
|
||||
public override EndPoint? LocalEndPoint { get; set; }
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ namespace Microsoft.AspNetCore.Connections.Features
|
|||
{
|
||||
public interface IConnectionIdFeature
|
||||
{
|
||||
string? ConnectionId { get; set; }
|
||||
string ConnectionId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ namespace Microsoft.AspNetCore.Connections.Features
|
|||
{
|
||||
public interface IConnectionItemsFeature
|
||||
{
|
||||
IDictionary<object, object?>? Items { get; set; }
|
||||
IDictionary<object, object?> Items { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ namespace Microsoft.AspNetCore.Connections.Features
|
|||
{
|
||||
public interface IConnectionTransportFeature
|
||||
{
|
||||
IDuplexPipe? Transport { get; set; }
|
||||
IDuplexPipe Transport { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Builder
|
|||
/// <param name="pattern">The route pattern.</param>
|
||||
/// <param name="configureOptions">A callback to configure dispatcher options.</param>
|
||||
/// <returns>An <see cref="ConnectionEndpointRouteBuilder"/> for endpoints associated with the connections.</returns>
|
||||
public static ConnectionEndpointRouteBuilder MapConnectionHandler<TConnectionHandler>(this IEndpointRouteBuilder endpoints, string pattern, Action<HttpConnectionDispatcherOptions> configureOptions) where TConnectionHandler : ConnectionHandler
|
||||
public static ConnectionEndpointRouteBuilder MapConnectionHandler<TConnectionHandler>(this IEndpointRouteBuilder endpoints, string pattern, Action<HttpConnectionDispatcherOptions>? configureOptions) where TConnectionHandler : ConnectionHandler
|
||||
{
|
||||
var options = new HttpConnectionDispatcherOptions();
|
||||
configureOptions?.Invoke(options);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Http.Connections
|
|||
/// SignalR connections can run on top of HTTP transports like WebSockets or Long Polling, or other non-HTTP transports. As a result,
|
||||
/// this method can sometimes return <see langword="null"/> depending on the configuration of your application.
|
||||
/// </remarks>
|
||||
public static HttpContext GetHttpContext(this ConnectionContext connection)
|
||||
public static HttpContext? GetHttpContext(this ConnectionContext connection)
|
||||
{
|
||||
return connection.Features.Get<IHttpContextFeature>()?.HttpContext;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
|
|
@ -10,52 +10,52 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
|
|||
{
|
||||
internal static class Log
|
||||
{
|
||||
private static readonly Action<ILogger, string, Exception> _connectionDisposed =
|
||||
private static readonly Action<ILogger, string, Exception?> _connectionDisposed =
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(1, "ConnectionDisposed"), "Connection {TransportConnectionId} was disposed.");
|
||||
|
||||
private static readonly Action<ILogger, string, string, Exception> _connectionAlreadyActive =
|
||||
private static readonly Action<ILogger, string, string, Exception?> _connectionAlreadyActive =
|
||||
LoggerMessage.Define<string, string>(LogLevel.Debug, new EventId(2, "ConnectionAlreadyActive"), "Connection {TransportConnectionId} is already active via {RequestId}.");
|
||||
|
||||
private static readonly Action<ILogger, string, string, Exception> _pollCanceled =
|
||||
private static readonly Action<ILogger, string, string, Exception?> _pollCanceled =
|
||||
LoggerMessage.Define<string, string>(LogLevel.Trace, new EventId(3, "PollCanceled"), "Previous poll canceled for {TransportConnectionId} on {RequestId}.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _establishedConnection =
|
||||
private static readonly Action<ILogger, Exception?> _establishedConnection =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(4, "EstablishedConnection"), "Establishing new connection.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _resumingConnection =
|
||||
private static readonly Action<ILogger, Exception?> _resumingConnection =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(5, "ResumingConnection"), "Resuming existing connection.");
|
||||
|
||||
private static readonly Action<ILogger, long, Exception> _receivedBytes =
|
||||
private static readonly Action<ILogger, long, Exception?> _receivedBytes =
|
||||
LoggerMessage.Define<long>(LogLevel.Trace, new EventId(6, "ReceivedBytes"), "Received {Count} bytes.");
|
||||
|
||||
private static readonly Action<ILogger, HttpTransportType, Exception> _transportNotSupported =
|
||||
private static readonly Action<ILogger, HttpTransportType, Exception?> _transportNotSupported =
|
||||
LoggerMessage.Define<HttpTransportType>(LogLevel.Debug, new EventId(7, "TransportNotSupported"), "{TransportType} transport not supported by this connection handler.");
|
||||
|
||||
private static readonly Action<ILogger, HttpTransportType, HttpTransportType, Exception> _cannotChangeTransport =
|
||||
private static readonly Action<ILogger, HttpTransportType, HttpTransportType, Exception?> _cannotChangeTransport =
|
||||
LoggerMessage.Define<HttpTransportType, HttpTransportType>(LogLevel.Debug, new EventId(8, "CannotChangeTransport"), "Cannot change transports mid-connection; currently using {TransportType}, requesting {RequestedTransport}.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _postNotallowedForWebsockets =
|
||||
private static readonly Action<ILogger, Exception?> _postNotallowedForWebsockets =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(9, "PostNotAllowedForWebSockets"), "POST requests are not allowed for websocket connections.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _negotiationRequest =
|
||||
private static readonly Action<ILogger, Exception?> _negotiationRequest =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(10, "NegotiationRequest"), "Sending negotiation response.");
|
||||
|
||||
private static readonly Action<ILogger, HttpTransportType, Exception> _receivedDeleteRequestForUnsupportedTransport =
|
||||
private static readonly Action<ILogger, HttpTransportType, Exception?> _receivedDeleteRequestForUnsupportedTransport =
|
||||
LoggerMessage.Define<HttpTransportType>(LogLevel.Trace, new EventId(11, "ReceivedDeleteRequestForUnsupportedTransport"), "Received DELETE request for unsupported transport: {TransportType}.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _terminatingConnection =
|
||||
private static readonly Action<ILogger, Exception?> _terminatingConnection =
|
||||
LoggerMessage.Define(LogLevel.Trace, new EventId(12, "TerminatingConection"), "Terminating Long Polling connection due to a DELETE request.");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _connectionDisposedWhileWriteInProgress =
|
||||
private static readonly Action<ILogger, string, Exception?> _connectionDisposedWhileWriteInProgress =
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(13, "ConnectionDisposedWhileWriteInProgress"), "Connection {TransportConnectionId} was disposed while a write was in progress.");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _failedToReadHttpRequestBody =
|
||||
private static readonly Action<ILogger, string, Exception?> _failedToReadHttpRequestBody =
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(14, "FailedToReadHttpRequestBody"), "Connection {TransportConnectionId} failed to read the HTTP request body.");
|
||||
|
||||
private static readonly Action<ILogger, int, Exception> _negotiateProtocolVersionMismatch =
|
||||
private static readonly Action<ILogger, int, Exception?> _negotiateProtocolVersionMismatch =
|
||||
LoggerMessage.Define<int>(LogLevel.Debug, new EventId(15, "NegotiateProtocolVersionMismatch"), "The client requested version '{clientProtocolVersion}', but the server does not support this version.");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _invalidNegotiateProtocolVersion =
|
||||
private static readonly Action<ILogger, string, Exception?> _invalidNegotiateProtocolVersion =
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(16, "InvalidNegotiateProtocolVersion"), "The client requested an invalid protocol version '{queryStringVersionValue}'");
|
||||
|
||||
public static void ConnectionDisposed(ILogger logger, string connectionId)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
|
|
@ -10,32 +10,32 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
|
|||
{
|
||||
private static class Log
|
||||
{
|
||||
private static readonly Action<ILogger, string, Exception> _createdNewConnection =
|
||||
private static readonly Action<ILogger, string, Exception?> _createdNewConnection =
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(1, "CreatedNewConnection"), "New connection {TransportConnectionId} created.");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _removedConnection =
|
||||
private static readonly Action<ILogger, string, Exception?> _removedConnection =
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(2, "RemovedConnection"), "Removing connection {TransportConnectionId} from the list of connections.");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _failedDispose =
|
||||
private static readonly Action<ILogger, string, Exception?> _failedDispose =
|
||||
LoggerMessage.Define<string>(LogLevel.Error, new EventId(3, "FailedDispose"), "Failed disposing connection {TransportConnectionId}.");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _connectionReset =
|
||||
private static readonly Action<ILogger, string, Exception?> _connectionReset =
|
||||
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(4, "ConnectionReset"), "Connection {TransportConnectionId} was reset.");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _connectionTimedOut =
|
||||
private static readonly Action<ILogger, string, Exception?> _connectionTimedOut =
|
||||
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(5, "ConnectionTimedOut"), "Connection {TransportConnectionId} timed out.");
|
||||
|
||||
// 6, ScanningConnections - removed
|
||||
|
||||
private static readonly Action<ILogger, Exception> _scanningConnectionsFailed =
|
||||
private static readonly Action<ILogger, Exception?> _scanningConnectionsFailed =
|
||||
LoggerMessage.Define(LogLevel.Error, new EventId(7, "ScanningConnectionsFailed"), "Scanning connections failed.");
|
||||
|
||||
// 8, ScannedConnections - removed
|
||||
|
||||
private static readonly Action<ILogger, Exception> _heartbeatStarted =
|
||||
private static readonly Action<ILogger, Exception?> _heartbeatStarted =
|
||||
LoggerMessage.Define(LogLevel.Trace, new EventId(9, "HeartBeatStarted"), "Starting connection heartbeat.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _heartbeatEnded =
|
||||
private static readonly Action<ILogger, Exception?> _heartbeatEnded =
|
||||
LoggerMessage.Define(LogLevel.Trace, new EventId(10, "HeartBeatEnded"), "Ending connection heartbeat.");
|
||||
|
||||
public static void CreatedNewConnection(ILogger logger, string connectionId)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.IO.Pipelines;
|
||||
using System.Net.WebSockets;
|
||||
|
|
@ -50,7 +51,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
|
|||
_ = ExecuteTimerLoop();
|
||||
}
|
||||
|
||||
internal bool TryGetConnection(string id, out HttpConnectionContext connection)
|
||||
internal bool TryGetConnection(string id, [NotNullWhen(true)] out HttpConnectionContext? connection)
|
||||
{
|
||||
connection = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Diagnostics.Tracing;
|
||||
using System.Threading;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports
|
|||
private readonly PipeReader _application;
|
||||
private readonly ILogger _logger;
|
||||
private readonly CancellationToken _timeoutToken;
|
||||
private readonly HttpConnectionContext _connection;
|
||||
private readonly HttpConnectionContext? _connection;
|
||||
|
||||
public LongPollingServerTransport(CancellationToken timeoutToken, PipeReader application, ILoggerFactory loggerFactory)
|
||||
: this(timeoutToken, application, loggerFactory, connection: null)
|
||||
{ }
|
||||
|
||||
public LongPollingServerTransport(CancellationToken timeoutToken, PipeReader application, ILoggerFactory loggerFactory, HttpConnectionContext connection)
|
||||
public LongPollingServerTransport(CancellationToken timeoutToken, PipeReader application, ILoggerFactory loggerFactory, HttpConnectionContext? connection)
|
||||
{
|
||||
_timeoutToken = timeoutToken;
|
||||
_application = application;
|
||||
|
|
@ -117,19 +117,19 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports
|
|||
|
||||
private static class Log
|
||||
{
|
||||
private static readonly Action<ILogger, Exception> _longPolling204 =
|
||||
private static readonly Action<ILogger, Exception?> _longPolling204 =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(1, "LongPolling204"), "Terminating Long Polling connection by sending 204 response.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _pollTimedOut =
|
||||
private static readonly Action<ILogger, Exception?> _pollTimedOut =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(2, "PollTimedOut"), "Poll request timed out. Sending 200 response to connection.");
|
||||
|
||||
private static readonly Action<ILogger, long, Exception> _longPollingWritingMessage =
|
||||
private static readonly Action<ILogger, long, Exception?> _longPollingWritingMessage =
|
||||
LoggerMessage.Define<long>(LogLevel.Trace, new EventId(3, "LongPollingWritingMessage"), "Writing a {Count} byte message to connection.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _longPollingDisconnected =
|
||||
private static readonly Action<ILogger, Exception?> _longPollingDisconnected =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(4, "LongPollingDisconnected"), "Client disconnected from Long Polling endpoint for connection.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _longPollingTerminated =
|
||||
private static readonly Action<ILogger, Exception?> _longPollingTerminated =
|
||||
LoggerMessage.Define(LogLevel.Error, new EventId(5, "LongPollingTerminated"), "Long Polling transport was terminated due to an error on connection.");
|
||||
|
||||
public static void LongPolling204(ILogger logger)
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports
|
|||
private readonly PipeReader _application;
|
||||
private readonly string _connectionId;
|
||||
private readonly ILogger _logger;
|
||||
private readonly HttpConnectionContext _connection;
|
||||
private readonly HttpConnectionContext? _connection;
|
||||
|
||||
public ServerSentEventsServerTransport(PipeReader application, string connectionId, ILoggerFactory loggerFactory)
|
||||
: this(application, connectionId, connection: null, loggerFactory)
|
||||
{ }
|
||||
|
||||
public ServerSentEventsServerTransport(PipeReader application, string connectionId, HttpConnectionContext connection, ILoggerFactory loggerFactory)
|
||||
public ServerSentEventsServerTransport(PipeReader application, string connectionId, HttpConnectionContext? connection, ILoggerFactory loggerFactory)
|
||||
{
|
||||
_application = application;
|
||||
_connectionId = connectionId;
|
||||
|
|
@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports
|
|||
|
||||
private static class Log
|
||||
{
|
||||
private static readonly Action<ILogger, long, Exception> _sseWritingMessage =
|
||||
private static readonly Action<ILogger, long, Exception?> _sseWritingMessage =
|
||||
LoggerMessage.Define<long>(LogLevel.Trace, new EventId(1, "SSEWritingMessage"), "Writing a {Count} byte message.");
|
||||
|
||||
public static void SSEWritingMessage(ILogger logger, long count)
|
||||
|
|
|
|||
|
|
@ -11,51 +11,51 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports
|
|||
{
|
||||
private static class Log
|
||||
{
|
||||
private static readonly Action<ILogger, string, Exception> _socketOpened =
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(1, "SocketOpened"), "Socket opened using Sub-Protocol: '{SubProtocol}'.");
|
||||
private static readonly Action<ILogger, string?, Exception?> _socketOpened =
|
||||
LoggerMessage.Define<string?>(LogLevel.Debug, new EventId(1, "SocketOpened"), "Socket opened using Sub-Protocol: '{SubProtocol}'.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _socketClosed =
|
||||
private static readonly Action<ILogger, Exception?> _socketClosed =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(2, "SocketClosed"), "Socket closed.");
|
||||
|
||||
private static readonly Action<ILogger, WebSocketCloseStatus?, string, Exception> _clientClosed =
|
||||
private static readonly Action<ILogger, WebSocketCloseStatus?, string, Exception?> _clientClosed =
|
||||
LoggerMessage.Define<WebSocketCloseStatus?, string>(LogLevel.Debug, new EventId(3, "ClientClosed"), "Client closed connection with status code '{Status}' ({Description}). Signaling end-of-input to application.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _waitingForSend =
|
||||
private static readonly Action<ILogger, Exception?> _waitingForSend =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(4, "WaitingForSend"), "Waiting for the application to finish sending data.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _failedSending =
|
||||
private static readonly Action<ILogger, Exception?> _failedSending =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(5, "FailedSending"), "Application failed during sending. Sending InternalServerError close frame.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _finishedSending =
|
||||
private static readonly Action<ILogger, Exception?> _finishedSending =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(6, "FinishedSending"), "Application finished sending. Sending close frame.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _waitingForClose =
|
||||
private static readonly Action<ILogger, Exception?> _waitingForClose =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(7, "WaitingForClose"), "Waiting for the client to close the socket.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _closeTimedOut =
|
||||
private static readonly Action<ILogger, Exception?> _closeTimedOut =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(8, "CloseTimedOut"), "Timed out waiting for client to send the close frame, aborting the connection.");
|
||||
|
||||
private static readonly Action<ILogger, WebSocketMessageType, int, bool, Exception> _messageReceived =
|
||||
private static readonly Action<ILogger, WebSocketMessageType, int, bool, Exception?> _messageReceived =
|
||||
LoggerMessage.Define<WebSocketMessageType, int, bool>(LogLevel.Trace, new EventId(9, "MessageReceived"), "Message received. Type: {MessageType}, size: {Size}, EndOfMessage: {EndOfMessage}.");
|
||||
|
||||
private static readonly Action<ILogger, int, Exception> _messageToApplication =
|
||||
private static readonly Action<ILogger, int, Exception?> _messageToApplication =
|
||||
LoggerMessage.Define<int>(LogLevel.Trace, new EventId(10, "MessageToApplication"), "Passing message to application. Payload size: {Size}.");
|
||||
|
||||
private static readonly Action<ILogger, long, Exception> _sendPayload =
|
||||
private static readonly Action<ILogger, long, Exception?> _sendPayload =
|
||||
LoggerMessage.Define<long>(LogLevel.Trace, new EventId(11, "SendPayload"), "Sending payload: {Size} bytes.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _errorWritingFrame =
|
||||
private static readonly Action<ILogger, Exception?> _errorWritingFrame =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(12, "ErrorWritingFrame"), "Error writing frame.");
|
||||
|
||||
// 13, SendFailed - removed
|
||||
|
||||
private static readonly Action<ILogger, Exception> _closedPrematurely =
|
||||
private static readonly Action<ILogger, Exception?> _closedPrematurely =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(14, "ClosedPrematurely"), "Socket connection closed prematurely.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _closingWebSocketFailed =
|
||||
private static readonly Action<ILogger, Exception?> _closingWebSocketFailed =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(15, "ClosingWebSocketFailed"), "Closing webSocket failed.");
|
||||
|
||||
public static void SocketOpened(ILogger logger, string subProtocol)
|
||||
public static void SocketOpened(ILogger logger, string? subProtocol)
|
||||
{
|
||||
_socketOpened(logger, subProtocol, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports
|
|||
|
||||
private async Task StartSending(WebSocket socket)
|
||||
{
|
||||
Exception error = null;
|
||||
Exception? error = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
|
||||
<IsAspNetCoreApp>true</IsAspNetCoreApp>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ namespace Microsoft.AspNetCore.Http.Connections
|
|||
// WebSocketManager's list of sub protocols is an IList:
|
||||
// https://github.com/aspnet/HttpAbstractions/blob/a6bdb9b1ec6ed99978a508e71a7f131be7e4d9fb/src/Microsoft.AspNetCore.Http.Abstractions/WebSocketManager.cs#L23
|
||||
// Unfortunately, IList<T> does not implement IReadOnlyList<T> :(
|
||||
public Func<IList<string>, string> SubProtocolSelector { get; set; }
|
||||
public Func<IList<string>, string>? SubProtocolSelector { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
<IsAspNetCoreApp>true</IsAspNetCoreApp>
|
||||
<RootNamespace>Microsoft.AspNetCore.SignalR</RootNamespace>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.SignalR.Protocol;
|
||||
|
||||
|
|
@ -9,7 +8,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
{
|
||||
public class MessagePackHubProtocolOptions
|
||||
{
|
||||
private MessagePackSerializerOptions _messagePackSerializerOptions;
|
||||
private MessagePackSerializerOptions? _messagePackSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Gets or sets the <see cref="MessagePackSerializerOptions"/> used internally by the <see cref="MessagePackSerializer" />.</para>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RootNamespace>Microsoft.AspNetCore.SignalR</RootNamespace>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>Implements the SignalR Hub Protocol using Newtonsoft.Json.</Description>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RootNamespace>Microsoft.AspNetCore.SignalR</RootNamespace>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Buffers;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Text.Encodings.Web;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
|
|
@ -69,7 +71,7 @@ namespace Microsoft.AspNetCore.Internal
|
|||
};
|
||||
}
|
||||
|
||||
public static string ReadAsString(this ref Utf8JsonReader reader, string propertyName)
|
||||
public static string? ReadAsString(this ref Utf8JsonReader reader, string propertyName)
|
||||
{
|
||||
reader.Read();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
|
|
@ -10,8 +12,8 @@ namespace Microsoft.AspNetCore.Internal
|
|||
{
|
||||
internal class TimerAwaitable : IDisposable, ICriticalNotifyCompletion
|
||||
{
|
||||
private Timer _timer;
|
||||
private Action _callback;
|
||||
private Timer? _timer;
|
||||
private Action? _callback;
|
||||
private static readonly Action _callbackCompleted = () => { };
|
||||
|
||||
private readonly TimeSpan _period;
|
||||
|
|
@ -55,7 +57,7 @@ namespace Microsoft.AspNetCore.Internal
|
|||
// If TimerAwaitable falls out of scope, the timer should be released.
|
||||
_timer = new Timer(state =>
|
||||
{
|
||||
var weakRef = (WeakReference<TimerAwaitable>)state;
|
||||
var weakRef = (WeakReference<TimerAwaitable>)state!;
|
||||
if (weakRef.TryGetTarget(out var thisRef))
|
||||
{
|
||||
thisRef.Tick();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
public HubException(string message) : base(message)
|
||||
public HubException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or <c>null</c> if no inner exception is specified.</param>
|
||||
public HubException(string message, Exception innerException) : base(message, innerException)
|
||||
public HubException(string? message, Exception? innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>Common serialiation primitives for SignalR Clients Servers</Description>
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
<IsAspNetCoreApp>true</IsAspNetCoreApp>
|
||||
<RootNamespace>Microsoft.AspNetCore.SignalR</RootNamespace>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <summary>
|
||||
/// Gets the optional error message.
|
||||
/// </summary>
|
||||
public string Error { get; }
|
||||
public string? Error { get; }
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="false"/>, clients with automatic reconnects enabled should not attempt to automatically reconnect after receiving the <see cref="CloseMessage"/>.
|
||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// Initializes a new instance of the <see cref="CloseMessage"/> class with an optional error message and <see cref="AllowReconnect"/> set to <see langword="false"/>.
|
||||
/// </summary>
|
||||
/// <param name="error">An optional error message.</param>
|
||||
public CloseMessage(string error)
|
||||
public CloseMessage(string? error)
|
||||
: this(error, allowReconnect: false)
|
||||
{
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <see langword="true"/>, if client with automatic reconnects enabled should attempt to reconnect after receiving the <see cref="CloseMessage"/>;
|
||||
/// <see langword="false"/>, if the client should not try to reconnect whether or not automatic reconnects are enabled.
|
||||
/// </param>
|
||||
public CloseMessage(string error, bool allowReconnect)
|
||||
public CloseMessage(string? error, bool allowReconnect)
|
||||
{
|
||||
Error = error;
|
||||
AllowReconnect = allowReconnect;
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||
{
|
||||
public class CompletionMessage : HubInvocationMessage
|
||||
{
|
||||
public string Error { get; }
|
||||
public object Result { get; }
|
||||
public string? Error { get; }
|
||||
public object? Result { get; }
|
||||
public bool HasResult { get; }
|
||||
|
||||
public CompletionMessage(string invocationId, string error, object result, bool hasResult)
|
||||
public CompletionMessage(string invocationId, string? error, object? result, bool hasResult)
|
||||
: base(invocationId)
|
||||
{
|
||||
if (error != null && result != null)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Buffers;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
|
@ -109,7 +110,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <param name="buffer">The serialized representation of the message.</param>
|
||||
/// <param name="responseMessage">When this method returns, contains the parsed message.</param>
|
||||
/// <returns>A value that is <c>true</c> if the <see cref="HandshakeResponseMessage"/> was successfully parsed; otherwise, <c>false</c>.</returns>
|
||||
public static bool TryParseResponseMessage(ref ReadOnlySequence<byte> buffer, out HandshakeResponseMessage responseMessage)
|
||||
public static bool TryParseResponseMessage(ref ReadOnlySequence<byte> buffer, [NotNullWhen(true)] out HandshakeResponseMessage? responseMessage)
|
||||
{
|
||||
if (!TextMessageParser.TryParseMessage(ref buffer, out var payload))
|
||||
{
|
||||
|
|
@ -122,7 +123,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
reader.CheckRead();
|
||||
reader.EnsureObjectStart();
|
||||
|
||||
string error = null;
|
||||
string? error = null;
|
||||
|
||||
while (reader.CheckRead())
|
||||
{
|
||||
|
|
@ -163,7 +164,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <param name="buffer">The serialized representation of the message.</param>
|
||||
/// <param name="requestMessage">When this method returns, contains the parsed message.</param>
|
||||
/// <returns>A value that is <c>true</c> if the <see cref="HandshakeRequestMessage"/> was successfully parsed; otherwise, <c>false</c>.</returns>
|
||||
public static bool TryParseRequestMessage(ref ReadOnlySequence<byte> buffer, out HandshakeRequestMessage requestMessage)
|
||||
public static bool TryParseRequestMessage(ref ReadOnlySequence<byte> buffer, [NotNullWhen(true)] out HandshakeRequestMessage? requestMessage)
|
||||
{
|
||||
if (!TextMessageParser.TryParseMessage(ref buffer, out var payload))
|
||||
{
|
||||
|
|
@ -176,7 +177,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
reader.CheckRead();
|
||||
reader.EnsureObjectStart();
|
||||
|
||||
string protocol = null;
|
||||
string? protocol = null;
|
||||
int? protocolVersion = null;
|
||||
|
||||
while (reader.CheckRead())
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <summary>
|
||||
/// Gets the optional error message.
|
||||
/// </summary>
|
||||
public string Error { get; }
|
||||
public string? Error { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HandshakeResponseMessage"/> class.
|
||||
/// An error response does need a minor version. Since the handshake has failed, any extra data will be ignored.
|
||||
/// </summary>
|
||||
/// <param name="error">Error encountered by the server, indicating why the handshake has failed.</param>
|
||||
public HandshakeResponseMessage(string error)
|
||||
public HandshakeResponseMessage(string? error)
|
||||
{
|
||||
Error = error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,18 +13,18 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <summary>
|
||||
/// Gets or sets a name/value collection of headers.
|
||||
/// </summary>
|
||||
public IDictionary<string, string> Headers { get; set; }
|
||||
public IDictionary<string, string>? Headers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the invocation ID.
|
||||
/// </summary>
|
||||
public string InvocationId { get; }
|
||||
public string? InvocationId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HubInvocationMessage"/> class.
|
||||
/// </summary>
|
||||
/// <param name="invocationId">The invocation ID.</param>
|
||||
protected HubInvocationMessage(string invocationId)
|
||||
protected HubInvocationMessage(string? invocationId)
|
||||
{
|
||||
InvocationId = invocationId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <summary>
|
||||
/// Gets the target method arguments.
|
||||
/// </summary>
|
||||
public object[] Arguments { get; }
|
||||
public object?[]? Arguments { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The target methods stream IDs.
|
||||
/// </summary>
|
||||
public string[] StreamIds { get; }
|
||||
public string[]? StreamIds { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HubMethodInvocationMessage"/> class.
|
||||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <param name="target">The target method name.</param>
|
||||
/// <param name="arguments">The target method arguments.</param>
|
||||
/// <param name="streamIds">The target methods stream IDs.</param>
|
||||
protected HubMethodInvocationMessage(string invocationId, string target, object[] arguments, string[] streamIds)
|
||||
protected HubMethodInvocationMessage(string? invocationId, string target, object?[]? arguments, string[]? streamIds)
|
||||
: this(invocationId, target, arguments)
|
||||
{
|
||||
StreamIds = streamIds;
|
||||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <param name="invocationId">The invocation ID.</param>
|
||||
/// <param name="target">The target method name.</param>
|
||||
/// <param name="arguments">The target method arguments.</param>
|
||||
protected HubMethodInvocationMessage(string invocationId, string target, object[] arguments)
|
||||
protected HubMethodInvocationMessage(string? invocationId, string target, object?[]? arguments)
|
||||
: base(invocationId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(target))
|
||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// </summary>
|
||||
/// <param name="target">The target method name.</param>
|
||||
/// <param name="arguments">The target method arguments.</param>
|
||||
public InvocationMessage(string target, object[] arguments)
|
||||
public InvocationMessage(string target, object?[]? arguments)
|
||||
: this(null, target, arguments)
|
||||
{
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <param name="invocationId">The invocation ID.</param>
|
||||
/// <param name="target">The target method name.</param>
|
||||
/// <param name="arguments">The target method arguments.</param>
|
||||
public InvocationMessage(string invocationId, string target, object[] arguments)
|
||||
public InvocationMessage(string? invocationId, string target, object?[]? arguments)
|
||||
: base(invocationId, target, arguments)
|
||||
{
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <param name="target">The target method name.</param>
|
||||
/// <param name="arguments">The target method arguments.</param>
|
||||
/// <param name="streamIds">The target methods stream IDs.</param>
|
||||
public InvocationMessage(string invocationId, string target, object[] arguments, string[] streamIds)
|
||||
public InvocationMessage(string? invocationId, string target, object?[]? arguments, string[]? streamIds)
|
||||
: base(invocationId, target, arguments, streamIds)
|
||||
{
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
string streamIds;
|
||||
try
|
||||
{
|
||||
args = string.Join(", ", Arguments?.Select(a => a?.ToString()));
|
||||
args = Arguments == null ? string.Empty : string.Join(", ", Arguments.Select(a => a?.ToString()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -158,7 +158,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
string streamIds;
|
||||
try
|
||||
{
|
||||
args = string.Join(", ", Arguments?.Select(a => a?.ToString()));
|
||||
args = Arguments == null ? string.Empty : string.Join(", ", Arguments.Select(a => a?.ToString()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.AspNetCore.Connections;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||
|
|
@ -34,7 +35,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
/// <param name="binder">The binder used to parse the message.</param>
|
||||
/// <param name="message">When this method returns <c>true</c>, contains the parsed message.</param>
|
||||
/// <returns>A value that is <c>true</c> if the <see cref="HubMessage"/> was successfully parsed; otherwise, <c>false</c>.</returns>
|
||||
bool TryParseMessage(ref ReadOnlySequence<byte> input, IInvocationBinder binder, out HubMessage message);
|
||||
bool TryParseMessage(ref ReadOnlySequence<byte> input, IInvocationBinder binder, [NotNullWhen(true)] out HubMessage message);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified <see cref="HubMessage"/> to a writer.
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
{
|
||||
public class StreamItemMessage : HubInvocationMessage
|
||||
{
|
||||
public object Item { get; }
|
||||
public object? Item { get; }
|
||||
|
||||
public StreamItemMessage(string invocationId, object item) : base(invocationId)
|
||||
public StreamItemMessage(string invocationId, object? item) : base(invocationId)
|
||||
{
|
||||
Item = item;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="arg1">The first argument.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous invoke.</returns>
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, CancellationToken cancellationToken = default)
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object? arg1, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return clientProxy.SendCoreAsync(method, new[] { arg1 }, cancellationToken);
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="arg2">The second argument.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous invoke.</returns>
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, CancellationToken cancellationToken = default)
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object? arg1, object? arg2, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return clientProxy.SendCoreAsync(method, new[] { arg1, arg2 }, cancellationToken);
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="arg3">The third argument.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous invoke.</returns>
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, CancellationToken cancellationToken = default)
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object? arg1, object? arg2, object? arg3, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3 }, cancellationToken);
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="arg4">The fourth argument.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous invoke.</returns>
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, CancellationToken cancellationToken = default)
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object? arg1, object? arg2, object? arg3, object? arg4, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4 }, cancellationToken);
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="arg5">The fifth argument.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous invoke.</returns>
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, CancellationToken cancellationToken = default)
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object? arg1, object? arg2, object? arg3, object? arg4, object? arg5, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5 }, cancellationToken);
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="arg6">The sixth argument.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous invoke.</returns>
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, CancellationToken cancellationToken = default)
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object? arg1, object? arg2, object? arg3, object? arg4, object? arg5, object? arg6, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5, arg6 }, cancellationToken);
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="arg7">The seventh argument.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous invoke.</returns>
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, CancellationToken cancellationToken = default)
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object? arg1, object? arg2, object? arg3, object? arg4, object? arg5, object? arg6, object? arg7, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }, cancellationToken);
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="arg8">The eigth argument.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous invoke.</returns>
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, CancellationToken cancellationToken = default)
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object? arg1, object? arg2, object? arg3, object? arg4, object? arg5, object? arg6, object? arg7, object? arg8, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }, cancellationToken);
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="arg9">The ninth argument.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous invoke.</returns>
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, CancellationToken cancellationToken = default)
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object? arg1, object? arg2, object? arg3, object? arg4, object? arg5, object? arg6, object? arg7, object? arg8, object? arg9, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }, cancellationToken);
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="arg10">The tenth argument.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous invoke.</returns>
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10, CancellationToken cancellationToken = default)
|
||||
public static Task SendAsync(this IClientProxy clientProxy, string method, object? arg1, object? arg2, object? arg3, object? arg4, object? arg5, object? arg6, object? arg7, object? arg8, object? arg9, object? arg10, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }, cancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,15 +80,15 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task SendAllAsync(string methodName, object[] args, CancellationToken cancellationToken = default)
|
||||
public override Task SendAllAsync(string methodName, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return SendToAllConnections(methodName, args, include: null, state: null, cancellationToken);
|
||||
}
|
||||
|
||||
private Task SendToAllConnections(string methodName, object[] args, Func<HubConnectionContext, object, bool> include, object state = null, CancellationToken cancellationToken = default)
|
||||
private Task SendToAllConnections(string methodName, object?[]? args, Func<HubConnectionContext, object?, bool>? include, object? state = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
List<Task> tasks = null;
|
||||
SerializedHubMessage message = null;
|
||||
List<Task>? tasks = null;
|
||||
SerializedHubMessage? message = null;
|
||||
|
||||
// foreach over HubConnectionStore avoids allocating an enumerator
|
||||
foreach (var connection in _connections)
|
||||
|
|
@ -127,7 +127,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
|
||||
// Tasks and message are passed by ref so they can be lazily created inside the method post-filtering,
|
||||
// while still being re-usable when sending to multiple groups
|
||||
private void SendToGroupConnections(string methodName, object[] args, ConcurrentDictionary<string, HubConnectionContext> connections, Func<HubConnectionContext, object, bool> include, object state, ref List<Task> tasks, ref SerializedHubMessage message, CancellationToken cancellationToken)
|
||||
private void SendToGroupConnections(string methodName, object?[]? args, ConcurrentDictionary<string, HubConnectionContext> connections, Func<HubConnectionContext, object?, bool>? include, object? state, ref List<Task>? tasks, ref SerializedHubMessage? message, CancellationToken cancellationToken)
|
||||
{
|
||||
// foreach over ConcurrentDictionary avoids allocating an enumerator
|
||||
foreach (var connection in connections)
|
||||
|
|
@ -157,7 +157,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task SendConnectionAsync(string connectionId, string methodName, object[] args, CancellationToken cancellationToken = default)
|
||||
public override Task SendConnectionAsync(string connectionId, string methodName, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (connectionId == null)
|
||||
{
|
||||
|
|
@ -179,7 +179,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task SendGroupAsync(string groupName, string methodName, object[] args, CancellationToken cancellationToken = default)
|
||||
public override Task SendGroupAsync(string groupName, string methodName, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (groupName == null)
|
||||
{
|
||||
|
|
@ -191,8 +191,8 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
{
|
||||
// Can't optimize for sending to a single connection in a group because
|
||||
// group might be modified inbetween checking and sending
|
||||
List<Task> tasks = null;
|
||||
SerializedHubMessage message = null;
|
||||
List<Task>? tasks = null;
|
||||
SerializedHubMessage? message = null;
|
||||
SendToGroupConnections(methodName, args, group, null, null, ref tasks, ref message, cancellationToken);
|
||||
|
||||
if (tasks != null)
|
||||
|
|
@ -205,11 +205,11 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task SendGroupsAsync(IReadOnlyList<string> groupNames, string methodName, object[] args, CancellationToken cancellationToken = default)
|
||||
public override Task SendGroupsAsync(IReadOnlyList<string> groupNames, string methodName, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
// Each task represents the list of tasks for each of the writes within a group
|
||||
List<Task> tasks = null;
|
||||
SerializedHubMessage message = null;
|
||||
List<Task>? tasks = null;
|
||||
SerializedHubMessage? message = null;
|
||||
|
||||
foreach (var groupName in groupNames)
|
||||
{
|
||||
|
|
@ -234,7 +234,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task SendGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList<string> excludedConnectionIds, CancellationToken cancellationToken = default)
|
||||
public override Task SendGroupExceptAsync(string groupName, string methodName, object?[]? args, IReadOnlyList<string> excludedConnectionIds, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (groupName == null)
|
||||
{
|
||||
|
|
@ -244,10 +244,10 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
var group = _groups[groupName];
|
||||
if (group != null)
|
||||
{
|
||||
List<Task> tasks = null;
|
||||
SerializedHubMessage message = null;
|
||||
List<Task>? tasks = null;
|
||||
SerializedHubMessage? message = null;
|
||||
|
||||
SendToGroupConnections(methodName, args, group, (connection, state) => !((IReadOnlyList<string>)state).Contains(connection.ConnectionId), excludedConnectionIds, ref tasks, ref message, cancellationToken);
|
||||
SendToGroupConnections(methodName, args, group, (connection, state) => !((IReadOnlyList<string>)state!).Contains(connection.ConnectionId), excludedConnectionIds, ref tasks, ref message, cancellationToken);
|
||||
|
||||
if (tasks != null)
|
||||
{
|
||||
|
|
@ -258,20 +258,20 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private SerializedHubMessage CreateSerializedInvocationMessage(string methodName, object[] args)
|
||||
private SerializedHubMessage CreateSerializedInvocationMessage(string methodName, object?[]? args)
|
||||
{
|
||||
return new SerializedHubMessage(CreateInvocationMessage(methodName, args));
|
||||
}
|
||||
|
||||
private HubMessage CreateInvocationMessage(string methodName, object[] args)
|
||||
private HubMessage CreateInvocationMessage(string methodName, object?[]? args)
|
||||
{
|
||||
return new InvocationMessage(methodName, args);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task SendUserAsync(string userId, string methodName, object[] args, CancellationToken cancellationToken = default)
|
||||
public override Task SendUserAsync(string userId, string methodName, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return SendToAllConnections(methodName, args, (connection, state) => string.Equals(connection.UserIdentifier, (string)state, StringComparison.Ordinal), userId, cancellationToken);
|
||||
return SendToAllConnections(methodName, args, (connection, state) => string.Equals(connection.UserIdentifier, (string)state!, StringComparison.Ordinal), userId, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
@ -290,21 +290,21 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task SendAllExceptAsync(string methodName, object[] args, IReadOnlyList<string> excludedConnectionIds, CancellationToken cancellationToken = default)
|
||||
public override Task SendAllExceptAsync(string methodName, object?[]? args, IReadOnlyList<string> excludedConnectionIds, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return SendToAllConnections(methodName, args, (connection, state) => !((IReadOnlyList<string>)state).Contains(connection.ConnectionId), excludedConnectionIds, cancellationToken);
|
||||
return SendToAllConnections(methodName, args, (connection, state) => !((IReadOnlyList<string>)state!).Contains(connection.ConnectionId), excludedConnectionIds, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task SendConnectionsAsync(IReadOnlyList<string> connectionIds, string methodName, object[] args, CancellationToken cancellationToken = default)
|
||||
public override Task SendConnectionsAsync(IReadOnlyList<string> connectionIds, string methodName, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return SendToAllConnections(methodName, args, (connection, state) => ((IReadOnlyList<string>)state).Contains(connection.ConnectionId), connectionIds, cancellationToken);
|
||||
return SendToAllConnections(methodName, args, (connection, state) => ((IReadOnlyList<string>)state!).Contains(connection.ConnectionId), connectionIds, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task SendUsersAsync(IReadOnlyList<string> userIds, string methodName, object[] args, CancellationToken cancellationToken = default)
|
||||
public override Task SendUsersAsync(IReadOnlyList<string> userIds, string methodName, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return SendToAllConnections(methodName, args, (connection, state) => ((IReadOnlyList<string>)state).Contains(connection.UserIdentifier), userIds, cancellationToken);
|
||||
return SendToAllConnections(methodName, args, (connection, state) => ((IReadOnlyList<string>)state!).Contains(connection.UserIdentifier), userIds, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Security.Claims;
|
||||
|
|
@ -12,9 +12,9 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
public class DefaultUserIdProvider : IUserIdProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public virtual string GetUserId(HubConnectionContext connection)
|
||||
public virtual string? GetUserId(HubConnectionContext connection)
|
||||
{
|
||||
return connection.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR
|
||||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// </summary>
|
||||
public abstract class DynamicHub : Hub
|
||||
{
|
||||
private DynamicHubClients _clients;
|
||||
private DynamicHubClients? _clients;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an object that can be used to invoke methods on the clients connected to this hub.
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
public abstract class Hub : IDisposable
|
||||
{
|
||||
private bool _disposed;
|
||||
private IHubCallerClients _clients;
|
||||
private HubCallerContext _context;
|
||||
private IGroupManager _groups;
|
||||
private IHubCallerClients _clients = default!;
|
||||
private HubCallerContext _context = default!;
|
||||
private IGroupManager _groups = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an object that can be used to invoke methods on the clients connected to this hub.
|
||||
|
|
@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// Called when a connection with the hub is terminated.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous disconnect.</returns>
|
||||
public virtual Task OnDisconnectedAsync(Exception exception)
|
||||
public virtual Task OnDisconnectedAsync(Exception? exception)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,17 +21,17 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <summary>
|
||||
/// Gets the user identifier.
|
||||
/// </summary>
|
||||
public abstract string UserIdentifier { get; }
|
||||
public abstract string? UserIdentifier { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user.
|
||||
/// </summary>
|
||||
public abstract ClaimsPrincipal User { get; }
|
||||
public abstract ClaimsPrincipal? User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a key/value collection that can be used to share data within the scope of this connection.
|
||||
/// </summary>
|
||||
public abstract IDictionary<object, object> Items { get; }
|
||||
public abstract IDictionary<object, object?> Items { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of HTTP features available on the connection.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,97 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR
|
||||
{
|
||||
public partial class HubConnectionContext
|
||||
{
|
||||
private static class Log
|
||||
{
|
||||
// Category: HubConnectionContext
|
||||
private static readonly Action<ILogger, string, Exception> _handshakeComplete =
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(1, "HandshakeComplete"), "Completed connection handshake. Using HubProtocol '{Protocol}'.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _handshakeCanceled =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(2, "HandshakeCanceled"), "Handshake was canceled.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _sentPing =
|
||||
LoggerMessage.Define(LogLevel.Trace, new EventId(3, "SentPing"), "Sent a ping message to the client.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _transportBufferFull =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(4, "TransportBufferFull"), "Unable to send Ping message to client, the transport buffer is full.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _handshakeFailed =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(5, "HandshakeFailed"), "Failed connection handshake.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _failedWritingMessage =
|
||||
LoggerMessage.Define(LogLevel.Error, new EventId(6, "FailedWritingMessage"), "Failed writing message. Aborting connection.");
|
||||
|
||||
private static readonly Action<ILogger, string, int, Exception> _protocolVersionFailed =
|
||||
LoggerMessage.Define<string, int>(LogLevel.Debug, new EventId(7, "ProtocolVersionFailed"), "Server does not support version {Version} of the {Protocol} protocol.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _abortFailed =
|
||||
LoggerMessage.Define(LogLevel.Trace, new EventId(8, "AbortFailed"), "Abort callback failed.");
|
||||
|
||||
private static readonly Action<ILogger, int, Exception> _clientTimeout =
|
||||
LoggerMessage.Define<int>(LogLevel.Debug, new EventId(9, "ClientTimeout"), "Client timeout ({ClientTimeout}ms) elapsed without receiving a message from the client. Closing connection.");
|
||||
|
||||
private static readonly Action<ILogger, long, Exception> _handshakeSizeLimitExceeded =
|
||||
LoggerMessage.Define<long>(LogLevel.Debug, new EventId(10, "HandshakeSizeLimitExceeded"), "The maximum message size of {MaxMessageSize}B was exceeded while parsing the Handshake. The message size can be configured in AddHubOptions.");
|
||||
|
||||
public static void HandshakeComplete(ILogger logger, string hubProtocol)
|
||||
{
|
||||
_handshakeComplete(logger, hubProtocol, null);
|
||||
}
|
||||
|
||||
public static void HandshakeCanceled(ILogger logger)
|
||||
{
|
||||
_handshakeCanceled(logger, null);
|
||||
}
|
||||
|
||||
public static void SentPing(ILogger logger)
|
||||
{
|
||||
_sentPing(logger, null);
|
||||
}
|
||||
|
||||
public static void TransportBufferFull(ILogger logger)
|
||||
{
|
||||
_transportBufferFull(logger, null);
|
||||
}
|
||||
|
||||
public static void HandshakeFailed(ILogger logger, Exception exception)
|
||||
{
|
||||
_handshakeFailed(logger, exception);
|
||||
}
|
||||
|
||||
public static void FailedWritingMessage(ILogger logger, Exception exception)
|
||||
{
|
||||
_failedWritingMessage(logger, exception);
|
||||
}
|
||||
|
||||
public static void ProtocolVersionFailed(ILogger logger, string protocolName, int version)
|
||||
{
|
||||
_protocolVersionFailed(logger, protocolName, version, null);
|
||||
}
|
||||
|
||||
public static void AbortFailed(ILogger logger, Exception exception)
|
||||
{
|
||||
_abortFailed(logger, exception);
|
||||
}
|
||||
|
||||
public static void ClientTimeout(ILogger logger, TimeSpan timeout)
|
||||
{
|
||||
_clientTimeout(logger, (int)timeout.TotalMilliseconds, null);
|
||||
}
|
||||
|
||||
public static void HandshakeSizeLimitExceeded(ILogger logger, long maxMessageSize)
|
||||
{
|
||||
_handshakeSizeLimitExceeded(logger, maxMessageSize, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,9 +23,9 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <summary>
|
||||
/// Encapsulates all information about an individual connection to a SignalR Hub.
|
||||
/// </summary>
|
||||
public class HubConnectionContext
|
||||
public partial class HubConnectionContext
|
||||
{
|
||||
private static readonly Action<object> _cancelReader = state => ((PipeReader)state).CancelPendingRead();
|
||||
private static readonly Action<object?> _cancelReader = state => ((PipeReader)state!).CancelPendingRead();
|
||||
private static readonly WaitCallback _abortedCallback = AbortConnection;
|
||||
|
||||
private readonly ConnectionContext _connectionContext;
|
||||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
private readonly ISystemClock _systemClock;
|
||||
private readonly CancellationTokenRegistration _closedRegistration;
|
||||
|
||||
private StreamTracker _streamTracker;
|
||||
private StreamTracker? _streamTracker;
|
||||
private long _lastSendTimeStamp;
|
||||
private ReadOnlyMemory<byte> _cachedPingMessage;
|
||||
private bool _clientTimeoutActive;
|
||||
|
|
@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
_connectionContext = connectionContext;
|
||||
_logger = loggerFactory.CreateLogger<HubConnectionContext>();
|
||||
ConnectionAborted = _connectionAbortedTokenSource.Token;
|
||||
_closedRegistration = connectionContext.ConnectionClosed.Register((state) => ((HubConnectionContext)state).Abort(), this);
|
||||
_closedRegistration = connectionContext.ConnectionClosed.Register((state) => ((HubConnectionContext)state!).Abort(), this);
|
||||
|
||||
HubCallerContext = new DefaultHubCallerContext(this);
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
|
||||
internal HubCallerContext HubCallerContext { get; }
|
||||
|
||||
internal Exception CloseException { get; private set; }
|
||||
internal Exception? CloseException { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="CancellationToken"/> that notifies when the connection is aborted.
|
||||
|
|
@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <summary>
|
||||
/// Gets the user for this connection.
|
||||
/// </summary>
|
||||
public virtual ClaimsPrincipal User => Features.Get<IConnectionUserFeature>()?.User;
|
||||
public virtual ClaimsPrincipal? User => Features.Get<IConnectionUserFeature>()?.User;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of features available on this connection.
|
||||
|
|
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <summary>
|
||||
/// Gets a key/value collection that can be used to share data within the scope of this connection.
|
||||
/// </summary>
|
||||
public virtual IDictionary<object, object> Items => _connectionContext.Items;
|
||||
public virtual IDictionary<object, object?> Items => _connectionContext.Items;
|
||||
|
||||
// Used by HubConnectionHandler to determine whether to set CloseMessage.AllowReconnect.
|
||||
internal bool AllowReconnect => _allowReconnect;
|
||||
|
|
@ -127,12 +127,12 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <summary>
|
||||
/// Gets or sets the user identifier for this connection.
|
||||
/// </summary>
|
||||
public string UserIdentifier { get; set; }
|
||||
public string? UserIdentifier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the protocol used by this connection.
|
||||
/// </summary>
|
||||
public virtual IHubProtocol Protocol { get; set; }
|
||||
public virtual IHubProtocol Protocol { get; set; } = default!;
|
||||
|
||||
// Currently used only for streaming methods
|
||||
internal ConcurrentDictionary<string, CancellationTokenSource> ActiveRequestCancellationSources { get; } = new ConcurrentDictionary<string, CancellationTokenSource>(StringComparer.Ordinal);
|
||||
|
|
@ -405,7 +405,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
ThreadPool.QueueUserWorkItem(_abortedCallback, this);
|
||||
}
|
||||
|
||||
internal async Task<bool> HandshakeAsync(TimeSpan timeout, IReadOnlyList<string> supportedProtocols, IHubProtocolResolver protocolResolver,
|
||||
internal async Task<bool> HandshakeAsync(TimeSpan timeout, IReadOnlyList<string>? supportedProtocols, IHubProtocolResolver protocolResolver,
|
||||
IUserIdProvider userIdProvider, bool enableDetailedErrors)
|
||||
{
|
||||
try
|
||||
|
|
@ -455,7 +455,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
consumed = segment.Start;
|
||||
examined = consumed;
|
||||
|
||||
Protocol = protocolResolver.GetProtocol(handshakeRequestMessage.Protocol, supportedProtocols);
|
||||
Protocol = protocolResolver.GetProtocol(handshakeRequestMessage.Protocol, supportedProtocols)!;
|
||||
if (Protocol == null)
|
||||
{
|
||||
Log.HandshakeFailed(_logger, null);
|
||||
|
|
@ -506,7 +506,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
}
|
||||
else if (overLength)
|
||||
{
|
||||
Log.HandshakeSizeLimitExceeded(_logger, _maxMessageSize.Value);
|
||||
Log.HandshakeSizeLimitExceeded(_logger, _maxMessageSize!.Value);
|
||||
await WriteHandshakeResponseAsync(new HandshakeResponseMessage("Handshake was canceled."));
|
||||
return false;
|
||||
}
|
||||
|
|
@ -619,9 +619,9 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
}
|
||||
}
|
||||
|
||||
private static void AbortConnection(object state)
|
||||
private static void AbortConnection(object? state)
|
||||
{
|
||||
var connection = (HubConnectionContext)state;
|
||||
var connection = (HubConnectionContext)state!;
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -684,89 +684,5 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
_streamTracker.CompleteAll(new OperationCanceledException("The underlying connection was closed."));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Log
|
||||
{
|
||||
// Category: HubConnectionContext
|
||||
private static readonly Action<ILogger, string, Exception> _handshakeComplete =
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(1, "HandshakeComplete"), "Completed connection handshake. Using HubProtocol '{Protocol}'.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _handshakeCanceled =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(2, "HandshakeCanceled"), "Handshake was canceled.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _sentPing =
|
||||
LoggerMessage.Define(LogLevel.Trace, new EventId(3, "SentPing"), "Sent a ping message to the client.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _transportBufferFull =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(4, "TransportBufferFull"), "Unable to send Ping message to client, the transport buffer is full.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _handshakeFailed =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(5, "HandshakeFailed"), "Failed connection handshake.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _failedWritingMessage =
|
||||
LoggerMessage.Define(LogLevel.Error, new EventId(6, "FailedWritingMessage"), "Failed writing message. Aborting connection.");
|
||||
|
||||
private static readonly Action<ILogger, string, int, Exception> _protocolVersionFailed =
|
||||
LoggerMessage.Define<string, int>(LogLevel.Debug, new EventId(7, "ProtocolVersionFailed"), "Server does not support version {Version} of the {Protocol} protocol.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _abortFailed =
|
||||
LoggerMessage.Define(LogLevel.Trace, new EventId(8, "AbortFailed"), "Abort callback failed.");
|
||||
|
||||
private static readonly Action<ILogger, int, Exception> _clientTimeout =
|
||||
LoggerMessage.Define<int>(LogLevel.Debug, new EventId(9, "ClientTimeout"), "Client timeout ({ClientTimeout}ms) elapsed without receiving a message from the client. Closing connection.");
|
||||
|
||||
private static readonly Action<ILogger, long, Exception> _handshakeSizeLimitExceeded =
|
||||
LoggerMessage.Define<long>(LogLevel.Debug, new EventId(10, "HandshakeSizeLimitExceeded"), "The maximum message size of {MaxMessageSize}B was exceeded while parsing the Handshake. The message size can be configured in AddHubOptions.");
|
||||
|
||||
public static void HandshakeComplete(ILogger logger, string hubProtocol)
|
||||
{
|
||||
_handshakeComplete(logger, hubProtocol, null);
|
||||
}
|
||||
|
||||
public static void HandshakeCanceled(ILogger logger)
|
||||
{
|
||||
_handshakeCanceled(logger, null);
|
||||
}
|
||||
|
||||
public static void SentPing(ILogger logger)
|
||||
{
|
||||
_sentPing(logger, null);
|
||||
}
|
||||
|
||||
public static void TransportBufferFull(ILogger logger)
|
||||
{
|
||||
_transportBufferFull(logger, null);
|
||||
}
|
||||
|
||||
public static void HandshakeFailed(ILogger logger, Exception exception)
|
||||
{
|
||||
_handshakeFailed(logger, exception);
|
||||
}
|
||||
|
||||
public static void FailedWritingMessage(ILogger logger, Exception exception)
|
||||
{
|
||||
_failedWritingMessage(logger, exception);
|
||||
}
|
||||
|
||||
public static void ProtocolVersionFailed(ILogger logger, string protocolName, int version)
|
||||
{
|
||||
_protocolVersionFailed(logger, protocolName, version, null);
|
||||
}
|
||||
|
||||
public static void AbortFailed(ILogger logger, Exception exception)
|
||||
{
|
||||
_abortFailed(logger, exception);
|
||||
}
|
||||
|
||||
public static void ClientTimeout(ILogger logger, TimeSpan timeout)
|
||||
{
|
||||
_clientTimeout(logger, (int)timeout.TotalMilliseconds, null);
|
||||
}
|
||||
|
||||
public static void HandshakeSizeLimitExceeded(ILogger logger, long maxMessageSize)
|
||||
{
|
||||
_handshakeSizeLimitExceeded(logger, maxMessageSize, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,6 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// </summary>
|
||||
public long? MaximumReceiveMessageSize { get; set; }
|
||||
|
||||
internal ISystemClock SystemClock { get; set; }
|
||||
internal ISystemClock SystemClock { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
|
||||
_enableDetailedErrors = false;
|
||||
|
||||
List<IHubFilter> hubFilters = null;
|
||||
List<IHubFilter>? hubFilters = null;
|
||||
if (_hubOptions.UserHasSetValues)
|
||||
{
|
||||
_maximumMessageSize = _hubOptions.MaximumReceiveMessageSize;
|
||||
|
|
@ -185,7 +185,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
await HubOnDisconnectedAsync(connection, connection.CloseException);
|
||||
}
|
||||
|
||||
private async Task HubOnDisconnectedAsync(HubConnectionContext connection, Exception exception)
|
||||
private async Task HubOnDisconnectedAsync(HubConnectionContext connection, Exception? exception)
|
||||
{
|
||||
// send close message before aborting the connection
|
||||
await SendCloseAsync(connection, exception, connection.AllowReconnect);
|
||||
|
|
@ -207,7 +207,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
}
|
||||
}
|
||||
|
||||
private async Task SendCloseAsync(HubConnectionContext connection, Exception exception, bool allowReconnect)
|
||||
private async Task SendCloseAsync(HubConnectionContext connection, Exception? exception, bool allowReconnect)
|
||||
{
|
||||
var closeMessage = CloseMessage.Empty;
|
||||
|
||||
|
|
@ -335,22 +335,22 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
|
||||
private static class Log
|
||||
{
|
||||
private static readonly Action<ILogger, string, Exception> _errorDispatchingHubEvent =
|
||||
private static readonly Action<ILogger, string, Exception?> _errorDispatchingHubEvent =
|
||||
LoggerMessage.Define<string>(LogLevel.Error, new EventId(1, "ErrorDispatchingHubEvent"), "Error when dispatching '{HubMethod}' on hub.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _errorProcessingRequest =
|
||||
private static readonly Action<ILogger, Exception?> _errorProcessingRequest =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(2, "ErrorProcessingRequest"), "Error when processing requests.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _abortFailed =
|
||||
private static readonly Action<ILogger, Exception?> _abortFailed =
|
||||
LoggerMessage.Define(LogLevel.Trace, new EventId(3, "AbortFailed"), "Abort callback failed.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _errorSendingClose =
|
||||
private static readonly Action<ILogger, Exception?> _errorSendingClose =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(4, "ErrorSendingClose"), "Error when sending Close message.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _connectedStarting =
|
||||
private static readonly Action<ILogger, Exception?> _connectedStarting =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(5, "ConnectedStarting"), "OnConnectedAsync started.");
|
||||
|
||||
private static readonly Action<ILogger, Exception> _connectedEnding =
|
||||
private static readonly Action<ILogger, Exception?> _connectedEnding =
|
||||
LoggerMessage.Define(LogLevel.Debug, new EventId(6, "ConnectedEnding"), "OnConnectedAsync ending.");
|
||||
|
||||
public static void ErrorDispatchingHubEvent(ILogger logger, string hubMethod, Exception exception)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
private readonly ConcurrentDictionary<string, HubConnectionContext> _connections =
|
||||
new ConcurrentDictionary<string, HubConnectionContext>(StringComparer.Ordinal);
|
||||
|
||||
public HubConnectionContext this[string connectionId]
|
||||
public HubConnectionContext? this[string connectionId]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// </summary>
|
||||
public class HubInvocationContext
|
||||
{
|
||||
internal ObjectMethodExecutor ObjectMethodExecutor { get; }
|
||||
internal ObjectMethodExecutor ObjectMethodExecutor { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of the <see cref="HubInvocationContext"/> class.
|
||||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="hub">The instance of the Hub.</param>
|
||||
/// <param name="hubMethod">The <see cref="MethodInfo"/> for the Hub method being invoked.</param>
|
||||
/// <param name="hubMethodArguments">The arguments provided by the client.</param>
|
||||
public HubInvocationContext(HubCallerContext context, IServiceProvider serviceProvider, Hub hub, MethodInfo hubMethod, IReadOnlyList<object> hubMethodArguments)
|
||||
public HubInvocationContext(HubCallerContext context, IServiceProvider serviceProvider, Hub hub, MethodInfo hubMethod, IReadOnlyList<object?> hubMethodArguments)
|
||||
{
|
||||
Hub = hub;
|
||||
ServiceProvider = serviceProvider;
|
||||
|
|
@ -40,12 +40,12 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="hubMethodName">The name of the Hub method being invoked.</param>
|
||||
/// <param name="hubMethodArguments">The arguments provided by the client.</param>
|
||||
[Obsolete("This constructor is obsolete and will be removed in a future version. The recommended alternative is to use the other constructor.")]
|
||||
public HubInvocationContext(HubCallerContext context, string hubMethodName, object[] hubMethodArguments)
|
||||
public HubInvocationContext(HubCallerContext context, string hubMethodName, object?[] hubMethodArguments)
|
||||
{
|
||||
throw new NotSupportedException("This constructor no longer works. Use the other constructor.");
|
||||
}
|
||||
|
||||
internal HubInvocationContext(ObjectMethodExecutor objectMethodExecutor, HubCallerContext context, IServiceProvider serviceProvider, Hub hub, object[] hubMethodArguments)
|
||||
internal HubInvocationContext(ObjectMethodExecutor objectMethodExecutor, HubCallerContext context, IServiceProvider serviceProvider, Hub hub, object?[] hubMethodArguments)
|
||||
: this(context, serviceProvider, hub, objectMethodExecutor.MethodInfo, hubMethodArguments)
|
||||
{
|
||||
ObjectMethodExecutor = objectMethodExecutor;
|
||||
|
|
@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <summary>
|
||||
/// Gets the arguments provided by the client.
|
||||
/// </summary>
|
||||
public IReadOnlyList<object> HubMethodArguments { get; }
|
||||
public IReadOnlyList<object?> HubMethodArguments { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IServiceProvider"/> specific to the scope of this Hub method invocation.
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="args">The invocation arguments.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous send.</returns>
|
||||
public abstract Task SendAllAsync(string methodName, object[] args, CancellationToken cancellationToken = default);
|
||||
public abstract Task SendAllAsync(string methodName, object?[]? args, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an invocation message to all hub connections excluding the specified connections.
|
||||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="excludedConnectionIds">A collection of connection IDs to exclude.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous send.</returns>
|
||||
public abstract Task SendAllExceptAsync(string methodName, object[] args, IReadOnlyList<string> excludedConnectionIds, CancellationToken cancellationToken = default);
|
||||
public abstract Task SendAllExceptAsync(string methodName, object?[]? args, IReadOnlyList<string> excludedConnectionIds, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an invocation message to the specified connection.
|
||||
|
|
@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="args">The invocation arguments.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous send.</returns>
|
||||
public abstract Task SendConnectionAsync(string connectionId, string methodName, object[] args, CancellationToken cancellationToken = default);
|
||||
public abstract Task SendConnectionAsync(string connectionId, string methodName, object?[]? args, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an invocation message to the specified connections.
|
||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="args">The invocation arguments.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous send.</returns>
|
||||
public abstract Task SendConnectionsAsync(IReadOnlyList<string> connectionIds, string methodName, object[] args, CancellationToken cancellationToken = default);
|
||||
public abstract Task SendConnectionsAsync(IReadOnlyList<string> connectionIds, string methodName, object?[]? args, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an invocation message to the specified group.
|
||||
|
|
@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="args">The invocation arguments.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous send.</returns>
|
||||
public abstract Task SendGroupAsync(string groupName, string methodName, object[] args, CancellationToken cancellationToken = default);
|
||||
public abstract Task SendGroupAsync(string groupName, string methodName, object?[]? args, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an invocation message to the specified groups.
|
||||
|
|
@ -85,7 +85,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="args">The invocation arguments.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous send.</returns>
|
||||
public abstract Task SendGroupsAsync(IReadOnlyList<string> groupNames, string methodName, object[] args, CancellationToken cancellationToken = default);
|
||||
public abstract Task SendGroupsAsync(IReadOnlyList<string> groupNames, string methodName, object?[]? args, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an invocation message to the specified group excluding the specified connections.
|
||||
|
|
@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="excludedConnectionIds">A collection of connection IDs to exclude.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous send.</returns>
|
||||
public abstract Task SendGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList<string> excludedConnectionIds, CancellationToken cancellationToken = default);
|
||||
public abstract Task SendGroupExceptAsync(string groupName, string methodName, object?[]? args, IReadOnlyList<string> excludedConnectionIds, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an invocation message to the specified user.
|
||||
|
|
@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="args">The invocation arguments.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous send.</returns>
|
||||
public abstract Task SendUserAsync(string userId, string methodName, object[] args, CancellationToken cancellationToken = default);
|
||||
public abstract Task SendUserAsync(string userId, string methodName, object?[]? args, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an invocation message to the specified users.
|
||||
|
|
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="args">The invocation arguments.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous send.</returns>
|
||||
public abstract Task SendUsersAsync(IReadOnlyList<string> userIds, string methodName, object[] args, CancellationToken cancellationToken = default);
|
||||
public abstract Task SendUsersAsync(IReadOnlyList<string> userIds, string methodName, object?[]? args, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a connection to the specified group.
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <summary>
|
||||
/// Gets or sets a collection of supported hub protocol names.
|
||||
/// </summary>
|
||||
public IList<string> SupportedProtocols { get; set; } = null;
|
||||
public IList<string>? SupportedProtocols { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum message size of a single incoming hub message. The default is 32KB.
|
||||
|
|
@ -52,6 +52,6 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// </summary>
|
||||
public int? StreamBufferCapacity { get; set; } = null;
|
||||
|
||||
internal List<IHubFilter> HubFilters { get; set; } = null;
|
||||
internal List<IHubFilter>? HubFilters { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
|
|
@ -17,7 +18,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
public void Configure(HubOptions<THub> options)
|
||||
{
|
||||
// Do a deep copy, otherwise users modifying the HubOptions<THub> list would be changing the global options list
|
||||
options.SupportedProtocols = new List<string>(_hubOptions.SupportedProtocols);
|
||||
options.SupportedProtocols = new List<string>(_hubOptions.SupportedProtocols ?? Array.Empty<string>());
|
||||
options.KeepAliveInterval = _hubOptions.KeepAliveInterval;
|
||||
options.HandshakeTimeout = _hubOptions.HandshakeTimeout;
|
||||
options.ClientTimeoutInterval = _hubOptions.ClientTimeoutInterval;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.SignalR.Internal;
|
||||
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <typeparam name="T">The type of client.</typeparam>
|
||||
public abstract class Hub<T> : Hub where T : class
|
||||
{
|
||||
private IHubCallerClients<T> _clients;
|
||||
private IHubCallerClients<T>? _clients;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <typeparamref name="T"/> that can be used to invoke methods on the clients connected to this hub.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="args">A collection of arguments to pass to the client.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous invoke.</returns>
|
||||
Task SendCoreAsync(string method, object[] args, CancellationToken cancellationToken = default);
|
||||
Task SendCoreAsync(string method, object?[]? args, CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
|
@ -19,7 +17,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="invocationContext">The context for the method invocation that holds all the important information about the invoke.</param>
|
||||
/// <param name="next">The next filter to run, and for the final one, the Hub invocation.</param>
|
||||
/// <returns>Returns the result of the Hub method invoke.</returns>
|
||||
ValueTask<object> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object>> next) => next(invocationContext);
|
||||
ValueTask<object?> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object?>> next) => next(invocationContext);
|
||||
|
||||
/// <summary>
|
||||
/// Allows handling of the <see cref="Hub.OnConnectedAsync"/> method.
|
||||
|
|
@ -36,6 +34,6 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="exception">The exception, if any, for the connection closing.</param>
|
||||
/// <param name="next">The next filter to run, and for the final one, the Hub invocation.</param>
|
||||
/// <returns></returns>
|
||||
Task OnDisconnectedAsync(HubLifetimeContext context, Exception exception, Func<HubLifetimeContext, Exception, Task> next) => next(context, exception);
|
||||
Task OnDisconnectedAsync(HubLifetimeContext context, Exception? exception, Func<HubLifetimeContext, Exception?, Task> next) => next(context, exception);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// <param name="protocolName">The protocol name.</param>
|
||||
/// <param name="supportedProtocols">A collection of supported protocols.</param>
|
||||
/// <returns>A matching <see cref="IHubProtocol"/> or <c>null</c> if no matching protocol was found.</returns>
|
||||
IHubProtocol GetProtocol(string protocolName, IReadOnlyList<string> supportedProtocols);
|
||||
IHubProtocol? GetProtocol(string protocolName, IReadOnlyList<string>? supportedProtocols);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR
|
||||
|
|
@ -14,6 +14,6 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
/// </summary>
|
||||
/// <param name="connection">The connection to get the user ID for.</param>
|
||||
/// <returns>The user ID for the specified connection.</returns>
|
||||
string GetUserId(HubConnectionContext connection);
|
||||
string? GetUserId(HubConnectionContext connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
public override string ConnectionId => _connection.ConnectionId;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string UserIdentifier => _connection.UserIdentifier;
|
||||
public override string? UserIdentifier => _connection.UserIdentifier;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ClaimsPrincipal User => _connection.User;
|
||||
public override ClaimsPrincipal? User => _connection.User;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IDictionary<object, object> Items => _connection.Items;
|
||||
public override IDictionary<object, object?> Items => _connection.Items;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IFeatureCollection Features => _connection.Features;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.SignalR.Protocol;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_hubProtocols = _availableProtocols.Values.ToList();
|
||||
}
|
||||
|
||||
public virtual IHubProtocol GetProtocol(string protocolName, IReadOnlyList<string> supportedProtocols)
|
||||
public virtual IHubProtocol? GetProtocol(string protocolName, IReadOnlyList<string>? supportedProtocols)
|
||||
{
|
||||
protocolName = protocolName ?? throw new ArgumentNullException(nameof(protocolName));
|
||||
|
||||
|
|
@ -49,10 +49,10 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
private static class Log
|
||||
{
|
||||
// Category: DefaultHubProtocolResolver
|
||||
private static readonly Action<ILogger, string, Type, Exception> _registeredSignalRProtocol =
|
||||
private static readonly Action<ILogger, string, Type, Exception?> _registeredSignalRProtocol =
|
||||
LoggerMessage.Define<string, Type>(LogLevel.Debug, new EventId(1, "RegisteredSignalRProtocol"), "Registered SignalR Protocol: {ProtocolName}, implemented by {ImplementationType}.");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _foundImplementationForProtocol =
|
||||
private static readonly Action<ILogger, string, Exception?> _foundImplementationForProtocol =
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(2, "FoundImplementationForProtocol"), "Found protocol implementation for requested protocol: {ProtocolName}.");
|
||||
|
||||
public static void RegisteredSignalRProtocol(ILogger logger, string protocolName, Type implementationType)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Dynamic;
|
||||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_clientProxy = clientProxy;
|
||||
}
|
||||
|
||||
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
|
||||
public override bool TryInvokeMember(InvokeMemberBinder binder, object?[]? args, out object? result)
|
||||
{
|
||||
result = _clientProxy.SendCoreAsync(binder.Name, args);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
internal abstract class HubDispatcher<THub> where THub : Hub
|
||||
{
|
||||
public abstract Task OnConnectedAsync(HubConnectionContext connection);
|
||||
public abstract Task OnDisconnectedAsync(HubConnectionContext connection, Exception exception);
|
||||
public abstract Task OnDisconnectedAsync(HubConnectionContext connection, Exception? exception);
|
||||
public abstract Task DispatchMessageAsync(HubConnectionContext connection, HubMessage hubMessage);
|
||||
public abstract IReadOnlyList<Type> GetParameterTypes(string name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -23,7 +21,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_filterType = filterType;
|
||||
}
|
||||
|
||||
public async ValueTask<object> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object>> next)
|
||||
public async ValueTask<object?> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object?>> next)
|
||||
{
|
||||
var (filter, owned) = GetFilter(invocationContext.ServiceProvider);
|
||||
|
||||
|
|
@ -57,7 +55,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public async Task OnDisconnectedAsync(HubLifetimeContext context, Exception exception, Func<HubLifetimeContext, Exception, Task> next)
|
||||
public async Task OnDisconnectedAsync(HubLifetimeContext context, Exception? exception, Func<HubLifetimeContext, Exception?, Task> next)
|
||||
{
|
||||
var (filter, owned) = GetFilter(context.ServiceProvider);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
|
@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
|
||||
private static readonly GroupConnectionList EmptyGroupConnectionList = new GroupConnectionList();
|
||||
|
||||
public ConcurrentDictionary<string, HubConnectionContext> this[string groupName]
|
||||
public ConcurrentDictionary<string, HubConnectionContext>? this[string groupName]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
|
||||
internal class GroupConnectionList : ConcurrentDictionary<string, HubConnectionContext>
|
||||
{
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is ConcurrentDictionary<string, HubConnectionContext> list)
|
||||
{
|
||||
|
|
@ -101,4 +101,4 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
|
||||
private static bool IsHubMethod(MethodInfo methodInfo)
|
||||
{
|
||||
var baseDefinition = methodInfo.GetBaseDefinition().DeclaringType;
|
||||
var baseDefinition = methodInfo.GetBaseDefinition().DeclaringType!;
|
||||
if (typeof(object) == baseDefinition || methodInfo.IsSpecialName)
|
||||
{
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_userId = userId;
|
||||
}
|
||||
|
||||
public Task SendCoreAsync(string method, object[] args, CancellationToken cancellationToken = default)
|
||||
public Task SendCoreAsync(string method, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _lifetimeManager.SendUserAsync(_userId, method, args, cancellationToken);
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_userIds = userIds;
|
||||
}
|
||||
|
||||
public Task SendCoreAsync(string method, object[] args, CancellationToken cancellationToken = default)
|
||||
public Task SendCoreAsync(string method, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _lifetimeManager.SendUsersAsync(_userIds, method, args, cancellationToken);
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_groupName = groupName;
|
||||
}
|
||||
|
||||
public Task SendCoreAsync(string method, object[] args, CancellationToken cancellationToken = default)
|
||||
public Task SendCoreAsync(string method, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _lifetimeManager.SendGroupAsync(_groupName, method, args, cancellationToken);
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_groupNames = groupNames;
|
||||
}
|
||||
|
||||
public Task SendCoreAsync(string method, object[] args, CancellationToken cancellationToken = default)
|
||||
public Task SendCoreAsync(string method, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _lifetimeManager.SendGroupsAsync(_groupNames, method, args, cancellationToken);
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_excludedConnectionIds = excludedConnectionIds;
|
||||
}
|
||||
|
||||
public Task SendCoreAsync(string method, object[] args, CancellationToken cancellationToken = default)
|
||||
public Task SendCoreAsync(string method, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _lifetimeManager.SendGroupExceptAsync(_groupName, method, args, _excludedConnectionIds, cancellationToken);
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_lifetimeManager = lifetimeManager;
|
||||
}
|
||||
|
||||
public Task SendCoreAsync(string method, object[] args, CancellationToken cancellationToken = default)
|
||||
public Task SendCoreAsync(string method, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _lifetimeManager.SendAllAsync(method, args, cancellationToken);
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_excludedConnectionIds = excludedConnectionIds;
|
||||
}
|
||||
|
||||
public Task SendCoreAsync(string method, object[] args, CancellationToken cancellationToken = default)
|
||||
public Task SendCoreAsync(string method, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _lifetimeManager.SendAllExceptAsync(method, args, _excludedConnectionIds, cancellationToken);
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_connectionId = connectionId;
|
||||
}
|
||||
|
||||
public Task SendCoreAsync(string method, object[] args, CancellationToken cancellationToken = default)
|
||||
public Task SendCoreAsync(string method, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _lifetimeManager.SendConnectionAsync(_connectionId, method, args, cancellationToken);
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
_connectionIds = connectionIds;
|
||||
}
|
||||
|
||||
public Task SendCoreAsync(string method, object[] args, CancellationToken cancellationToken = default)
|
||||
public Task SendCoreAsync(string method, object?[]? args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _lifetimeManager.SendConnectionsAsync(_connectionIds, method, args, cancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<IsAspNetCoreApp>true</IsAspNetCoreApp>
|
||||
<RootNamespace>Microsoft.AspNetCore.SignalR</RootNamespace>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
{
|
||||
private SerializedMessage _cachedItem1;
|
||||
private SerializedMessage _cachedItem2;
|
||||
private List<SerializedMessage> _cachedItems;
|
||||
private List<SerializedMessage>? _cachedItems;
|
||||
private readonly object _lock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hub message for the serialization cache.
|
||||
/// </summary>
|
||||
public HubMessage Message { get; }
|
||||
public HubMessage? Message { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SerializedHubMessage"/> class.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
Loading…
Reference in New Issue