← Back to Files
ActiveConversationService.cs
namespace KaiChat.Services;
public interface IActiveConversationService
{
void SetActive(string conversationId);
string? GetActiveConversationId();
}
public sealed class ActiveConversationService : IActiveConversationService
{
private readonly object _gate = new();
private string? _conversationId;
public void SetActive(string conversationId)
{
if (string.IsNullOrWhiteSpace(conversationId))
return;
lock (_gate)
{
_conversationId = conversationId;
}
}
public string? GetActiveConversationId()
{
lock (_gate)
{
return _conversationId;
}
}
}