diff --git a/src/Microsoft.AspNetCore.SignalR.Core/IHubClientsExtensions.cs b/src/Microsoft.AspNetCore.SignalR.Core/IHubClientsExtensions.cs new file mode 100644 index 0000000000..0d19846948 --- /dev/null +++ b/src/Microsoft.AspNetCore.SignalR.Core/IHubClientsExtensions.cs @@ -0,0 +1,558 @@ +// 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; + +namespace Microsoft.AspNetCore.SignalR +{ + public static class IHubClientsExtensions + { + /// + /// + /// + /// The first connection to exclude. + /// + public static T AllExcept(this IHubClients hubClients, string excludedConnectionId1) + { + return hubClients.AllExcept(new [] { excludedConnectionId1 }); + } + + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// + public static T AllExcept(this IHubClients hubClients, string excludedConnectionId1, string excludedConnectionId2) + { + return hubClients.AllExcept(new [] { excludedConnectionId1, excludedConnectionId2 }); + } + + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// + public static T AllExcept(this IHubClients hubClients, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3) + { + return hubClients.AllExcept(new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3 }); + } + + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// The fourth connection to exclude. + /// + public static T AllExcept(this IHubClients hubClients, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3, string excludedConnectionId4) + { + return hubClients.AllExcept(new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3, excludedConnectionId4 }); + } + + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// The fourth connection to exclude. + /// The fifth connection to exclude. + /// + public static T AllExcept(this IHubClients hubClients, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3, string excludedConnectionId4, string excludedConnectionId5) + { + return hubClients.AllExcept(new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3, excludedConnectionId4, excludedConnectionId5 }); + } + + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// The fourth connection to exclude. + /// The fifth connection to exclude. + /// The sixth connection to exclude. + /// + public static T AllExcept(this IHubClients hubClients, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3, string excludedConnectionId4, string excludedConnectionId5, string excludedConnectionId6) + { + return hubClients.AllExcept(new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3, excludedConnectionId4, excludedConnectionId5, excludedConnectionId6 }); + } + + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// The fourth connection to exclude. + /// The fifth connection to exclude. + /// The sixth connection to exclude. + /// The seventh connection to exclude. + /// + public static T AllExcept(this IHubClients hubClients, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3, string excludedConnectionId4, string excludedConnectionId5, string excludedConnectionId6, string excludedConnectionId7) + { + return hubClients.AllExcept(new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3, excludedConnectionId4, excludedConnectionId5, excludedConnectionId6, excludedConnectionId7 }); + } + + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// The fourth connection to exclude. + /// The fifth connection to exclude. + /// The sixth connection to exclude. + /// The seventh connection to exclude. + /// The eighth connection to exclude. + /// + public static T AllExcept(this IHubClients hubClients, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3, string excludedConnectionId4, string excludedConnectionId5, string excludedConnectionId6, string excludedConnectionId7, string excludedConnectionId8) + { + return hubClients.AllExcept(new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3, excludedConnectionId4, excludedConnectionId5, excludedConnectionId6, excludedConnectionId7, excludedConnectionId8 }); + } + + /// + /// + /// + /// The first connection to include. + /// + public static T Clients(this IHubClients hubClients, string connection1) + { + return hubClients.Clients(new [] { connection1 }); + } + + /// + /// + /// + /// The first connection to include. + /// The second connection to include. + /// + public static T Clients(this IHubClients hubClients, string connection1, string connection2) + { + return hubClients.Clients(new [] { connection1, connection2 }); + } + + /// + /// + /// + /// The first connection to include. + /// The second connection to include. + /// The third connection to include. + /// + public static T Clients(this IHubClients hubClients, string connection1, string connection2, string connection3) + { + return hubClients.Clients(new [] { connection1, connection2, connection3 }); + } + + /// + /// + /// + /// The first connection to include. + /// The second connection to include. + /// The third connection to include. + /// The fourth connection to include. + /// + public static T Clients(this IHubClients hubClients, string connection1, string connection2, string connection3, string connection4) + { + return hubClients.Clients(new [] { connection1, connection2, connection3, connection4 }); + } + + /// + /// + /// + /// The first connection to include. + /// The second connection to include. + /// The third connection to include. + /// The fourth connection to include. + /// The fifth connection to include. + /// + public static T Clients(this IHubClients hubClients, string connection1, string connection2, string connection3, string connection4, string connection5) + { + return hubClients.Clients(new [] { connection1, connection2, connection3, connection4, connection5 }); + } + + /// + /// + /// + /// The first connection to include. + /// The second connection to include. + /// The third connection to include. + /// The fourth connection to include. + /// The fifth connection to include. + /// The sixth connection to include. + /// + public static T Clients(this IHubClients hubClients, string connection1, string connection2, string connection3, string connection4, string connection5, string connection6) + { + return hubClients.Clients(new [] { connection1, connection2, connection3, connection4, connection5, connection6 }); + } + + /// + /// + /// + /// The first connection to include. + /// The second connection to include. + /// The third connection to include. + /// The fourth connection to include. + /// The fifth connection to include. + /// The sixth connection to include. + /// The seventh connection to include. + /// + public static T Clients(this IHubClients hubClients, string connection1, string connection2, string connection3, string connection4, string connection5, string connection6, string connection7) + { + return hubClients.Clients(new [] { connection1, connection2, connection3, connection4, connection5, connection6, connection7 }); + } + + /// + /// + /// + /// The first connection to include. + /// The second connection to include. + /// The third connection to include. + /// The fourth connection to include. + /// The fifth connection to include. + /// The sixth connection to include. + /// The seventh connection to include. + /// The eighth connection to include. + /// + public static T Clients(this IHubClients hubClients, string connection1, string connection2, string connection3, string connection4, string connection5, string connection6, string connection7, string connection8) + { + return hubClients.Clients(new [] { connection1, connection2, connection3, connection4, connection5, connection6, connection7, connection8 }); + } + + /// + /// + /// + /// The first group to include. + /// + public static T Groups(this IHubClients hubClients, string group1) + { + return hubClients.Groups(new [] { group1 }); + } + + /// + /// + /// + /// The first group to include. + /// The second group to include. + /// + public static T Groups(this IHubClients hubClients, string group1, string group2) + { + return hubClients.Groups(new [] { group1, group2 }); + } + + /// + /// + /// + /// The first group to include. + /// The second group to include. + /// The third group to include. + /// + public static T Groups(this IHubClients hubClients, string group1, string group2, string group3) + { + return hubClients.Groups(new [] { group1, group2, group3 }); + } + + /// + /// + /// + /// The first group to include. + /// The second group to include. + /// The third group to include. + /// The fourth group to include. + /// + public static T Groups(this IHubClients hubClients, string group1, string group2, string group3, string group4) + { + return hubClients.Groups(new [] { group1, group2, group3, group4 }); + } + + /// + /// + /// + /// The first group to include. + /// The second group to include. + /// The third group to include. + /// The fourth group to include. + /// The fifth group to include. + /// + public static T Groups(this IHubClients hubClients, string group1, string group2, string group3, string group4, string group5) + { + return hubClients.Groups(new [] { group1, group2, group3, group4, group5 }); + } + + /// + /// + /// + /// The first group to include. + /// The second group to include. + /// The third group to include. + /// The fourth group to include. + /// The fifth group to include. + /// The sixth group to include. + /// + public static T Groups(this IHubClients hubClients, string group1, string group2, string group3, string group4, string group5, string group6) + { + return hubClients.Groups(new [] { group1, group2, group3, group4, group5, group6 }); + } + + /// + /// + /// + /// The first group to include. + /// The second group to include. + /// The third group to include. + /// The fourth group to include. + /// The fifth group to include. + /// The sixth group to include. + /// The seventh group to include. + /// + public static T Groups(this IHubClients hubClients, string group1, string group2, string group3, string group4, string group5, string group6, string group7) + { + return hubClients.Groups(new [] { group1, group2, group3, group4, group5, group6, group7 }); + } + + /// + /// + /// + /// The first group to include. + /// The second group to include. + /// The third group to include. + /// The fourth group to include. + /// The fifth group to include. + /// The sixth group to include. + /// The seventh group to include. + /// The eighth group to include. + /// + public static T Groups(this IHubClients hubClients, string group1, string group2, string group3, string group4, string group5, string group6, string group7, string group8) + { + return hubClients.Groups(new [] { group1, group2, group3, group4, group5, group6, group7, group8 }); + } + + /// + /// + /// + /// + /// The first connection to exclude. + /// + public static T GroupExcept(this IHubClients hubClients, string groupName, string excludedConnectionId1) + { + return hubClients.GroupExcept(groupName, new [] { excludedConnectionId1 }); + } + + /// + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// + public static T GroupExcept(this IHubClients hubClients, string groupName, string excludedConnectionId1, string excludedConnectionId2) + { + return hubClients.GroupExcept(groupName, new [] { excludedConnectionId1, excludedConnectionId2 }); + } + + /// + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// + public static T GroupExcept(this IHubClients hubClients, string groupName, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3) + { + return hubClients.GroupExcept(groupName, new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3 }); + } + + /// + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// The fourth connection to exclude. + /// + public static T GroupExcept(this IHubClients hubClients, string groupName, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3, string excludedConnectionId4) + { + return hubClients.GroupExcept(groupName, new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3, excludedConnectionId4 }); + } + + /// + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// The fourth connection to exclude. + /// The fifth connection to exclude. + /// + public static T GroupExcept(this IHubClients hubClients, string groupName, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3, string excludedConnectionId4, string excludedConnectionId5) + { + return hubClients.GroupExcept(groupName, new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3, excludedConnectionId4, excludedConnectionId5 }); + } + + /// + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// The fourth connection to exclude. + /// The fifth connection to exclude. + /// The sixth connection to exclude. + /// + public static T GroupExcept(this IHubClients hubClients, string groupName, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3, string excludedConnectionId4, string excludedConnectionId5, string excludedConnectionId6) + { + return hubClients.GroupExcept(groupName, new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3, excludedConnectionId4, excludedConnectionId5, excludedConnectionId6 }); + } + + /// + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// The fourth connection to exclude. + /// The fifth connection to exclude. + /// The sixth connection to exclude. + /// The seventh connection to exclude. + /// + public static T GroupExcept(this IHubClients hubClients, string groupName, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3, string excludedConnectionId4, string excludedConnectionId5, string excludedConnectionId6, string excludedConnectionId7) + { + return hubClients.GroupExcept(groupName, new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3, excludedConnectionId4, excludedConnectionId5, excludedConnectionId6, excludedConnectionId7 }); + } + + /// + /// + /// + /// + /// The first connection to exclude. + /// The second connection to exclude. + /// The third connection to exclude. + /// The fourth connection to exclude. + /// The fifth connection to exclude. + /// The sixth connection to exclude. + /// The seventh connection to exclude. + /// The eighth connection to exclude. + /// + public static T GroupExcept(this IHubClients hubClients, string groupName, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3, string excludedConnectionId4, string excludedConnectionId5, string excludedConnectionId6, string excludedConnectionId7, string excludedConnectionId8) + { + return hubClients.GroupExcept(groupName, new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3, excludedConnectionId4, excludedConnectionId5, excludedConnectionId6, excludedConnectionId7, excludedConnectionId8 }); + } + + /// + /// + /// + /// The first user to include. + /// + public static T Users(this IHubClients hubClients, string user1) + { + return hubClients.Users(new [] { user1 }); + } + + /// + /// + /// + /// The first user to include. + /// The second user to include. + /// + public static T Users(this IHubClients hubClients, string user1, string user2) + { + return hubClients.Users(new [] { user1, user2 }); + } + + /// + /// + /// + /// The first user to include. + /// The second user to include. + /// The third user to include. + /// + public static T Users(this IHubClients hubClients, string user1, string user2, string user3) + { + return hubClients.Users(new [] { user1, user2, user3 }); + } + + /// + /// + /// + /// The first user to include. + /// The second user to include. + /// The third user to include. + /// The fourth user to include. + /// + public static T Users(this IHubClients hubClients, string user1, string user2, string user3, string user4) + { + return hubClients.Users(new [] { user1, user2, user3, user4 }); + } + + /// + /// + /// + /// The first user to include. + /// The second user to include. + /// The third user to include. + /// The fourth user to include. + /// The fifth user to include. + /// + public static T Users(this IHubClients hubClients, string user1, string user2, string user3, string user4, string user5) + { + return hubClients.Users(new [] { user1, user2, user3, user4, user5 }); + } + + /// + /// + /// + /// The first user to include. + /// The second user to include. + /// The third user to include. + /// The fourth user to include. + /// The fifth user to include. + /// The sixth user to include. + /// + public static T Users(this IHubClients hubClients, string user1, string user2, string user3, string user4, string user5, string user6) + { + return hubClients.Users(new [] { user1, user2, user3, user4, user5, user6 }); + } + + /// + /// + /// + /// The first user to include. + /// The second user to include. + /// The third user to include. + /// The fourth user to include. + /// The fifth user to include. + /// The sixth user to include. + /// The seventh user to include. + /// + public static T Users(this IHubClients hubClients, string user1, string user2, string user3, string user4, string user5, string user6, string user7) + { + return hubClients.Users(new [] { user1, user2, user3, user4, user5, user6, user7 }); + } + + /// + /// + /// + /// The first user to include. + /// The second user to include. + /// The third user to include. + /// The fourth user to include. + /// The fifth user to include. + /// The sixth user to include. + /// The seventh user to include. + /// The eighth user to include. + /// + public static T Users(this IHubClients hubClients, string user1, string user2, string user3, string user4, string user5, string user6, string user7, string user8) + { + return hubClients.Users(new [] { user1, user2, user3, user4, user5, user6, user7, user8 }); + } + } +}