/// <summary> /// Invokes a hub method on the server using the specified method name and arguments. /// </summary> /// <typeparam name="TResult">The return type of the server method.</typeparam> /// <param name="hubConnection">The hub connection.</param> /// <param name="methodName">The name of the server method to invoke.</param> /// <param name="args">The arguments used to invoke the server method.</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{TResult}"/> that represents the asynchronous invoke. /// The <see cref="Task{TResult}.Result"/> property returns a <typeparamref name="TResult"/> for the hub method return value. /// </returns> public static async Task <TResult> InvokeCoreAsync <TResult>(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)) !); }
/// <summary> /// Invokes a hub method on the server using the specified method name and arguments. /// </summary> /// <param name="hubConnection">The hub connection.</param> /// <param name="methodName">The name of the server method to invoke.</param> /// <param name="args">The arguments used to invoke the server method.</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 InvokeCoreAsync(this HubConnection hubConnection, string methodName, object[] args, CancellationToken cancellationToken = default) { if (hubConnection == null) { throw new ArgumentNullException(nameof(hubConnection)); } return(hubConnection.InvokeCoreAsync(methodName, typeof(object), args, cancellationToken)); }
public static Task <TResult> InvokeAsync <TResult>(this HubConnection hubConnection, string methodName, object?arg1, object?arg2, object?arg3, CancellationToken cancellationToken = default) { return(hubConnection.InvokeCoreAsync <TResult>(methodName, new[] { arg1, arg2, arg3 }, cancellationToken)); }
public static Task <TResult> InvokeAsync <TResult>(this HubConnection hubConnection, string methodName, CancellationToken cancellationToken = default) { return(hubConnection.InvokeCoreAsync <TResult>(methodName, Array.Empty <object>(), cancellationToken)); }
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)); }
/// <summary> /// Invokes a hub method on the server using the specified method name and arguments. /// </summary> /// <typeparam name="TResult">The return type of the server method.</typeparam> /// <param name="hubConnection">The hub connection.</param> /// <param name="methodName">The name of the server method to invoke.</param> /// <param name="arg1">The first argument.</param> /// <param name="arg2">The second argument.</param> /// <param name="arg3">The third argument.</param> /// <param name="arg4">The fourth argument.</param> /// <param name="arg5">The fifth argument.</param> /// <param name="arg6">The sixth argument.</param> /// <param name="arg7">The seventh argument.</param> /// <param name="arg8">The eighth argument.</param> /// <param name="arg9">The ninth argument.</param> /// <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{TResult}"/> that represents the asynchronous invoke. /// The <see cref="Task{TResult}.Result"/> property returns a <typeparamref name="TResult"/> for the hub method return value. /// </returns> public static Task <TResult> InvokeAsync <TResult>(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 <TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }, cancellationToken)); }