Add contact preferences announcement
Persist contact options and announce them on chat connection and reconnection. Prepare the audio-only call contract; enforcement and audio-only media remain unimplemented. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
0886b5e4e7
commit
9c4cce6840
11 changed files with 150 additions and 5 deletions
|
|
@ -9,6 +9,14 @@ namespace Yavsc.Server.Hubs;
|
|||
|
||||
public partial class ChatHub
|
||||
{
|
||||
public void SetContactPreferences(ContactPreferences preferences)
|
||||
{
|
||||
CallUser();
|
||||
if (preferences is null)
|
||||
throw new HubException("Contact preferences are required.");
|
||||
_calls.SetContactPreferences(Context.ConnectionId, preferences);
|
||||
}
|
||||
|
||||
public Task<CallSession> InviteCall(string roomName, string callee) =>
|
||||
InviteCoreAsync(roomName, callee, CallTransports.WebRtc);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Collections.Concurrent;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
|
@ -33,8 +34,15 @@ public sealed class CallSignalingService(
|
|||
|
||||
private readonly SemaphoreSlim _gate = new(1);
|
||||
private readonly Dictionary<Guid, PendingCall> _calls = [];
|
||||
private readonly ConcurrentDictionary<string, ContactPreferences> _contactPreferences = new();
|
||||
private readonly AudioVideoCallOptions _options = options.Value;
|
||||
|
||||
public void SetContactPreferences(string connection, ContactPreferences preferences) =>
|
||||
_contactPreferences[connection] = preferences;
|
||||
|
||||
public ContactPreferences? GetContactPreferences(string connection) =>
|
||||
_contactPreferences.TryGetValue(connection, out var preferences) ? preferences : null;
|
||||
|
||||
public async Task<CallSession> InviteAsync(
|
||||
string room, string caller, string callee, string callerConnection,
|
||||
string[] calleeConnections, bool relayOnly, string transport = CallTransports.WebRtc)
|
||||
|
|
@ -207,6 +215,7 @@ public sealed class CallSignalingService(
|
|||
|
||||
public async Task DisconnectAsync(string connection)
|
||||
{
|
||||
_contactPreferences.TryRemove(connection, out _);
|
||||
await _gate.WaitAsync();
|
||||
try
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue