Групповые звонки
This commit is contained in:
@@ -363,6 +363,7 @@ public sealed class ChatHub : Hub
|
||||
var userInfo = new ParticipantInfo(userId, username, displayName, avatar);
|
||||
|
||||
var participants = _groupCallParticipants.GetOrAdd(chatId, _ => new ConcurrentDictionary<string, ParticipantInfo>());
|
||||
var isFirst = participants.IsEmpty;
|
||||
participants.TryAdd(userId, userInfo);
|
||||
|
||||
// Notify others
|
||||
@@ -380,6 +381,17 @@ public sealed class ChatHub : Hub
|
||||
chatId = chatId,
|
||||
participants = others
|
||||
});
|
||||
|
||||
if (isFirst)
|
||||
{
|
||||
await Clients.Group(chatId).SendAsync("group_call_incoming", new
|
||||
{
|
||||
chatId = chatId,
|
||||
from = userId,
|
||||
callerInfo = userInfo,
|
||||
callType = request.CallType
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[HubMethodName("group_call_leave")]
|
||||
@@ -393,6 +405,7 @@ public sealed class ChatHub : Hub
|
||||
if (participants.IsEmpty)
|
||||
{
|
||||
_groupCallParticipants.TryRemove(chatId, out _);
|
||||
await Clients.Group(chatId).SendAsync("group_call_ended", new { chatId = chatId });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user