experimental-ext-interceptors/csharp/sdk/samples/AvatarMoodInterceptorSample/AvatarState.cs
Peder Holdgaard Pedersen d01a626b76
C# Re-implementation (#5)
Re-implementation of C# interceptors SDK with clearer focus on
server-side / gateway interceptors.
Fixes a lot of issues with the existing implementation.
Still more boilerplate than I'm happy with, but this is better than what
was there. Will refine further in later PRs.
2026-05-14 15:11:41 +02:00

36 lines
824 B
C#

namespace AvatarMoodInterceptorSample;
public enum Mood
{
Neutral,
Happy,
Curious,
Focused,
Confused,
Frustrated,
}
public sealed class AvatarState
{
private readonly object _lock = new();
private readonly List<Mood> _history = [];
public Mood Current { get; private set; } = Mood.Neutral;
public float Confidence { get; private set; }
public string? ClassifierModel { get; private set; }
public IReadOnlyList<Mood> History
{
get { lock (_lock) { return _history.ToArray(); } }
}
public void Update(Mood mood, float confidence, string? classifierModel)
{
lock (_lock)
{
Current = mood;
Confidence = confidence;
ClassifierModel = classifierModel;
_history.Add(mood);
}
}
}