enhanced UDP audio sender/receiver scripts with metrics for packet tracking and improved NPC assignment logic
This commit is contained in:
@ -70,6 +70,16 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
|
||||
public event Action<bool> OnRecordingStateChanged;
|
||||
|
||||
// Metrics for debug UI
|
||||
private int _totalPacketsSent = 0;
|
||||
private DateTime _lastPacketSentTime;
|
||||
public int TotalPacketsSent => _totalPacketsSent;
|
||||
public float TimeSinceLastSend => _lastPacketSentTime != default ?
|
||||
(float)(DateTime.UtcNow - _lastPacketSentTime).TotalSeconds : -1f;
|
||||
public string CurrentTargetIP => targetIP;
|
||||
public int CurrentTargetPort => targetPort;
|
||||
public bool UsingDiscovery => NetworkConfig.Instance?.useAutoDiscovery ?? false;
|
||||
|
||||
[Header("Recording Storage")]
|
||||
[SerializeField] private bool saveLocalAudio = true;
|
||||
[SerializeField] private int localSampleRate = 16000;
|
||||
@ -609,6 +619,10 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
// Send the packet
|
||||
await _udpClient.SendAsync(packet, packet.Length, _targetEndPoint);
|
||||
|
||||
// Update metrics
|
||||
_totalPacketsSent++;
|
||||
_lastPacketSentTime = DateTime.UtcNow;
|
||||
|
||||
if (enableDebugLogging && _packetSequence % 10 == 0) // Log every 10th packet
|
||||
{
|
||||
ConvaiLogger.DebugLog($"Sent packet {_packetSequence} with {currentChunkSamples} samples", ConvaiLogger.LogCategory.Character);
|
||||
|
||||
Reference in New Issue
Block a user