// 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 Microsoft.AspNetCore.SignalR.Internal;
namespace Microsoft.AspNetCore.SignalR
{
///
/// A class that provides dynamic access to connections, including the one that sent the current invocation.
///
public class DynamicHubClients
{
private readonly IHubCallerClients _clients;
///
/// Initializes a new instance of the class.
///
/// A wrapped that is used to invoke methods.
public DynamicHubClients(IHubCallerClients clients)
{
_clients = clients;
}
///
/// Gets an object that can be used to invoke methods on all clients connected to the hub.
///
/// An object that can be used to invoke methods on the specified user.
public dynamic All => new DynamicClientProxy(_clients.All);
///
/// Gets an object that can be used to invoke methods on all clients connected to the hub excluding the specified connections.
///
/// A collection of connection IDs to exclude.
/// An object that can be used to invoke methods on the specified user.
public dynamic AllExcept(IReadOnlyList excludedConnectionIds) => new DynamicClientProxy(_clients.AllExcept(excludedConnectionIds));
///
/// Gets an object that can be used to invoke methods on the connection which triggered the current invocation.
///
public dynamic Caller => new DynamicClientProxy(_clients.Caller);
///
/// Gets an object that can be used to invoke methods on the specified connection.
///
/// The connection ID.
/// An object that can be used to invoke methods.
public dynamic Client(string connectionId) => new DynamicClientProxy(_clients.Client(connectionId));
///
/// Gets an object that can be used to invoke methods on the specified connections.
///
/// The connection IDs.
/// An object that can be used to invoke methods.
public dynamic Clients(IReadOnlyList connectionIds) => new DynamicClientProxy(_clients.Clients(connectionIds));
///
/// Gets an object that can be used to invoke methods on all connections in the specified group.
///
/// The group name.
/// An object that can be used to invoke methods.
public dynamic Group(string groupName) => new DynamicClientProxy(_clients.Group(groupName));
///
/// Gets an object that can be used to invoke methods on all connections in all of the specified groups.
///
/// The group names.
/// An object that can be used to invoke methods on the specified user.
public dynamic Groups(IReadOnlyList groupNames) => new DynamicClientProxy(_clients.Groups(groupNames));
///
/// Gets an object that can be used to invoke methods on all connections in the specified group excluding the specified connections.
///
/// The group name.
/// A collection of connection IDs to exclude.
/// An object that can be used to invoke methods.
public dynamic GroupExcept(string groupName, IReadOnlyList excludedConnectionIds) => new DynamicClientProxy(_clients.GroupExcept(groupName, excludedConnectionIds));
///
/// Gets an object that can be used to invoke methods on connections in a group other than the caller.
///
/// An object that can be used to invoke methods.
public dynamic OthersInGroup(string groupName) => new DynamicClientProxy(_clients.OthersInGroup(groupName));
///
/// Gets an object that can be used to invoke methods on connections other than the caller.
///
public dynamic Others => new DynamicClientProxy(_clients.Others);
///
/// Gets an object that can be used to invoke methods on all connections associated with the specified user.
///
/// The user ID.
/// An object that can be used to invoke methods.
public dynamic User(string userId) => new DynamicClientProxy(_clients.User(userId));
///
/// Gets an object that can be used to invoke methods on all connections associated with all of the specified users.
///
/// The user IDs.
/// An object that can be used to invoke methods.
public dynamic Users(IReadOnlyList userIds) => new DynamicClientProxy(_clients.Users(userIds));
}
}