在 AspNet.SignalR.Core 中,
IHubConnectionContext
中有此方法,您可以在其中向组列表发送响应,同时排除某些连接 ID,即:
T Groups(IList<string> groupNames, params string[] excludeConnectionIds);
这将被称为:
Clients.Groups(groupNames, exconnectionIds).ReceiveCollaborationNotification(response);
现在我已经迁移到
AspNetCore.SignalR.Core
,并且没有这样的方法可以同时接受要排除的组名称和连接 ID 列表。它确实有下面提到的方法,但这个方法只接受一个组名称,而不是一个列表。
T GroupExcept(string groupName, IReadOnlyList<string> excludedConnectionIds);
我怎样才能实现
T Groups(IList<string> groupNames, params string[] excludeConnectionIds
在AspNetCore.SignalR.Core
中所做的事情
在 SignalR Core 中,你有这个扩展方法:
public static T GroupExcept<T> (this Microsoft.AspNetCore.SignalR.IHubClients<T> hubClients, string groupName, string excludedConnectionId1, string excludedConnectionId2, string excludedConnectionId3, string excludedConnectionId4, string excludedConnectionId5, string excludedConnectionId6, string excludedConnectionId7, string excludedConnectionId8);
您可以在此处阅读更多相关信息。
因此,要实现您想要的目标,您将需要使用这些扩展方法。