// 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.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.SignalR.Client
{
///
/// Extension methods for .
///
public static partial class HubConnectionExtensions
{
///
/// Invokes a hub method on the server using the specified method name.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, CancellationToken cancellationToken = default)
{
return hubConnection.InvokeCoreAsync(methodName, Array.Empty(), cancellationToken);
}
///
/// Invokes a hub method on the server using the specified method name and argument.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The first argument.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, CancellationToken cancellationToken = default)
{
return hubConnection.InvokeCoreAsync(methodName, new[] { arg1 }, cancellationToken);
}
///
/// Invokes a hub method on the server using the specified method name and arguments.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The first argument.
/// The second argument.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, CancellationToken cancellationToken = default)
{
return hubConnection.InvokeCoreAsync(methodName, new[] { arg1, arg2 }, cancellationToken);
}
///
/// Invokes a hub method on the server using the specified method name and arguments.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The first argument.
/// The second argument.
/// The third argument.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, CancellationToken cancellationToken = default)
{
return hubConnection.InvokeCoreAsync(methodName, new[] { arg1, arg2, arg3 }, cancellationToken);
}
///
/// Invokes a hub method on the server using the specified method name and arguments.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The first argument.
/// The second argument.
/// The third argument.
/// The fourth argument.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, CancellationToken cancellationToken = default)
{
return hubConnection.InvokeCoreAsync(methodName, new[] { arg1, arg2, arg3, arg4 }, cancellationToken);
}
///
/// Invokes a hub method on the server using the specified method name and arguments.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The first argument.
/// The second argument.
/// The third argument.
/// The fourth argument.
/// The fifth argument.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, CancellationToken cancellationToken = default)
{
return hubConnection.InvokeCoreAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5 }, cancellationToken);
}
///
/// Invokes a hub method on the server using the specified method name and arguments.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The first argument.
/// The second argument.
/// The third argument.
/// The fourth argument.
/// The fifth argument.
/// The sixth argument.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, CancellationToken cancellationToken = default)
{
return hubConnection.InvokeCoreAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6 }, cancellationToken);
}
///
/// Invokes a hub method on the server using the specified method name and arguments.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The first argument.
/// The second argument.
/// The third argument.
/// The fourth argument.
/// The fifth argument.
/// The sixth argument.
/// The seventh argument.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, CancellationToken cancellationToken = default)
{
return hubConnection.InvokeCoreAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }, cancellationToken);
}
///
/// Invokes a hub method on the server using the specified method name and arguments.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The first argument.
/// The second argument.
/// The third argument.
/// The fourth argument.
/// The fifth argument.
/// The sixth argument.
/// The seventh argument.
/// The eighth argument.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, CancellationToken cancellationToken = default)
{
return hubConnection.InvokeCoreAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }, cancellationToken);
}
///
/// Invokes a hub method on the server using the specified method name and arguments.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The first argument.
/// The second argument.
/// The third argument.
/// The fourth argument.
/// The fifth argument.
/// The sixth argument.
/// The seventh argument.
/// The eighth argument.
/// The ninth argument.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, CancellationToken cancellationToken = default)
{
return hubConnection.InvokeCoreAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }, cancellationToken);
}
///
/// Invokes a hub method on the server using the specified method name and arguments.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The first argument.
/// The second argument.
/// The third argument.
/// The fourth argument.
/// The fifth argument.
/// The sixth argument.
/// The seventh argument.
/// The eighth argument.
/// The ninth argument.
/// The tenth argument.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10, CancellationToken cancellationToken = default)
{
return hubConnection.InvokeCoreAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }, cancellationToken);
}
///
/// Invokes a hub method on the server using the specified method name and arguments.
///
/// The return type of the server method.
/// The hub connection.
/// The name of the server method to invoke.
/// The arguments used to invoke the server method.
/// The token to monitor for cancellation requests. The default value is .
///
/// A that represents the asynchronous invoke.
/// The property returns a for the hub method return value.
///
public static async Task InvokeCoreAsync(this HubConnection hubConnection, string methodName, object[] args, CancellationToken cancellationToken = default)
{
if (hubConnection == null)
{
throw new ArgumentNullException(nameof(hubConnection));
}
return (TResult)await hubConnection.InvokeCoreAsync(methodName, typeof(TResult), args, cancellationToken);
}
}
}