Skip to content

Commit 3c574ef

Browse files
committed
Add more extensions for Groups, GroupsExcept, etc...
1 parent 500ab60 commit 3c574ef

File tree

1 file changed

+51
-7
lines changed

1 file changed

+51
-7
lines changed

src/SignalR/server/Core/src/HubClientsExtensions.cs

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ public static T AllExcept<T>(this IHubClients<T> hubClients, string excludedConn
127127
return hubClients.AllExcept(new [] { excludedConnectionId1, excludedConnectionId2, excludedConnectionId3, excludedConnectionId4, excludedConnectionId5, excludedConnectionId6, excludedConnectionId7, excludedConnectionId8 });
128128
}
129129

130+
/// <summary>
131+
/// Gets a <typeparamref name="T" /> that can be used to invoke methods on all clients connected to the hub excluding the specified connections.
132+
/// </summary>
133+
/// <param name="hubClients">The abstraction that provides access to connections.</param>
134+
/// <param name="excludedConnectionIds">The connection IDs to exclude.</param>
135+
/// <returns>A <typeparamref name="T" /> representing the methods that can be invoked on the clients.</returns>
136+
public static T AllExcept<T>(this IHubClients<T> hubClients, IEnumerable<string> excludedConnectionIds)
137+
{
138+
return hubClients.AllExcept(excludedConnectionIds.ToList());
139+
}
140+
130141
/// <summary>
131142
/// Gets a <typeparamref name="T" /> that can be used to invoke methods on the specified connections.
132143
/// </summary>
@@ -243,6 +254,17 @@ public static T Clients<T>(this IHubClients<T> hubClients, string connection1, s
243254
return hubClients.Clients(new [] { connection1, connection2, connection3, connection4, connection5, connection6, connection7, connection8 });
244255
}
245256

257+
/// <summary>
258+
/// Gets a <typeparamref name="T" /> that can be used to invoke methods on the specified connections.
259+
/// </summary>
260+
/// <param name="hubClients">The abstraction that provides access to connections.</param>
261+
/// <param name="connectionIds">The connection IDs.</param>
262+
/// <returns>A <typeparamref name="T" /> representing the methods that can be invoked on the clients.</returns>
263+
public static T Clients<T>(this IHubClients<T> hubClients, IEnumerable<string> connectionIds)
264+
{
265+
return hubClients.Clients(connectionIds.ToList());
266+
}
267+
246268
/// <summary>
247269
/// Gets a <typeparamref name="T" /> that can be used to invoke methods on all connections in all of the specified groups.
248270
/// </summary>
@@ -359,6 +381,17 @@ public static T Groups<T>(this IHubClients<T> hubClients, string group1, string
359381
return hubClients.Groups(new [] { group1, group2, group3, group4, group5, group6, group7, group8 });
360382
}
361383

384+
/// <summary>
385+
/// Gets a <typeparamref name="T" /> that can be used to invoke methods on all connections in all of the specified groups.
386+
/// </summary>
387+
/// <param name="hubClients">The abstraction that provides access to connections.</param>
388+
/// <param name="groupNames">The group names.</param>
389+
/// <returns>A <typeparamref name="T" /> representing the methods that can be invoked on the clients.</returns>
390+
public static T Groups<T>(this IHubClients<T> hubClients, IEnumerable<string> groupNames)
391+
{
392+
return hubClients.Groups(groupNames.ToList());
393+
}
394+
362395
/// <summary>
363396
/// Gets a <typeparamref name="T" /> that can be used to invoke methods on all connections in the specified group excluding the specified connections.
364397
/// </summary>
@@ -484,25 +517,25 @@ public static T GroupExcept<T>(this IHubClients<T> hubClients, string groupName,
484517
}
485518

486519
/// <summary>
487-
/// Gets a <typeparamref name="T" /> that can be used to invoke methods on all connections associated with all of the specified users.
520+
/// Gets a <typeparamref name="T" /> that can be used to invoke methods on all connections in the specified group excluding the specified connections.
488521
/// </summary>
489522
/// <param name="hubClients">The abstraction that provides access to connections.</param>
490-
/// <param name="user1">The first user to include.</param>
523+
/// <param name="excludedConnectionIds">The connection IDs to exclude.</param>
491524
/// <returns>A <typeparamref name="T" /> representing the methods that can be invoked on the clients.</returns>
492-
public static T Users<T>(this IHubClients<T> hubClients, string user1)
525+
public static T GroupExcept<T>(this IHubClients<T> hubClients, IEnumerable<string> excludedConnectionIds)
493526
{
494-
return hubClients.Users(new [] { user1 });
527+
return hubClients.GroupExcept(excludedConnectionIds.ToList());
495528
}
496529

497530
/// <summary>
498531
/// Gets a <typeparamref name="T" /> that can be used to invoke methods on all connections associated with all of the specified users.
499532
/// </summary>
500533
/// <param name="hubClients">The abstraction that provides access to connections.</param>
501-
/// <param name="userIds">The user IDs.</param>
534+
/// <param name="user1">The first user to include.</param>
502535
/// <returns>A <typeparamref name="T" /> representing the methods that can be invoked on the clients.</returns>
503-
public static T Users<T>(this IHubClients<T> hubClients, IEnumerable<string> userIds)
536+
public static T Users<T>(this IHubClients<T> hubClients, string user1)
504537
{
505-
return hubClients.Users(userIds.ToList());
538+
return hubClients.Users(new [] { user1 });
506539
}
507540

508541
/// <summary>
@@ -609,5 +642,16 @@ public static T Users<T>(this IHubClients<T> hubClients, string user1, string us
609642
{
610643
return hubClients.Users(new [] { user1, user2, user3, user4, user5, user6, user7, user8 });
611644
}
645+
646+
/// <summary>
647+
/// Gets a <typeparamref name="T" /> that can be used to invoke methods on all connections associated with all of the specified users.
648+
/// </summary>
649+
/// <param name="hubClients">The abstraction that provides access to connections.</param>
650+
/// <param name="userIds">The user IDs.</param>
651+
/// <returns>A <typeparamref name="T" /> representing the methods that can be invoked on the clients.</returns>
652+
public static T Users<T>(this IHubClients<T> hubClients, IEnumerable<string> userIds)
653+
{
654+
return hubClients.Users(userIds.ToList());
655+
}
612656
}
613657
}

0 commit comments

Comments
 (0)