SignalR을 사용하고 있습니다. 대화가 끝나면 모든 수신자를 대화에 추가하려고합니다.SignalR and Groups.Add in foreach
모든 코드가 좋지만 첫 번째 수신자에게만 알립니다. 그래서 방송이 처음
public void NotifyConversation(ConversationModel model, string name)
{
var groupId = model.ID.ToString();
var recipients = model.Recipients;
var allconnections = new List<string>();
foreach (var recipient in recipients)
{
var connections = _manager.GetConnections(recipient.Name).Where(x => x != null);
allconnections.AddRange(connections);
}
var tasks = allconnections
.Select(connection =>
Task.Run(() => { Context.Groups.Add(connection, groupId); })).ToArray();
Task.WaitAll(tasks);
Context.Clients.Group(groupId).broadcastConversation(model);
}
어떤 이유인지 그것은 나를 위해 작동하지 않습니다 ... –