removed legacy avatar synchronization scripts and server implementation, transitioning to a new UDP-based system for improved performance and efficiency
This commit is contained in:
@ -19,10 +19,7 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
public class ConvaiSimpleUDPAudioReceiver : MonoBehaviour
|
||||
{
|
||||
[Header("Network Configuration")]
|
||||
[SerializeField] private int listenPort = 12345;
|
||||
[SerializeField] private bool enableDebugLogging = true;
|
||||
[SerializeField] private bool useGlobalNetworkConfig = true;
|
||||
[SerializeField] private NetworkConfig networkConfigAsset;
|
||||
|
||||
[Header("NPC Target")]
|
||||
[SerializeField] private bool useActiveNPC = true;
|
||||
@ -35,6 +32,7 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
private UdpClient _udpListener;
|
||||
private IPEndPoint _remoteEndPoint;
|
||||
private bool _isListening = false;
|
||||
private int listenPort;
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
// Audio state tracking
|
||||
@ -78,15 +76,19 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
{
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
_persistentDataPath = Application.persistentDataPath;
|
||||
// Apply global config if enabled
|
||||
if (useGlobalNetworkConfig)
|
||||
|
||||
// Get network config from global instance
|
||||
var cfg = NetworkConfig.Instance;
|
||||
if (cfg != null)
|
||||
{
|
||||
var cfg = networkConfigAsset != null ? networkConfigAsset : NetworkConfig.Instance;
|
||||
if (cfg != null)
|
||||
{
|
||||
listenPort = cfg.multiplayerAudioPort;
|
||||
}
|
||||
listenPort = cfg.port;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("NetworkConfig not found! Please ensure NetworkConfig.asset exists in Resources folder.");
|
||||
listenPort = 1221;
|
||||
}
|
||||
|
||||
InitializeNetwork();
|
||||
InitializeConvai();
|
||||
|
||||
|
||||
@ -20,10 +20,7 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
public class ConvaiSimpleUDPAudioSender : MonoBehaviour
|
||||
{
|
||||
[Header("Network Settings")]
|
||||
[SerializeField] private string targetIP = "127.0.0.1";
|
||||
[SerializeField] private int targetPort = 12345;
|
||||
[SerializeField] private bool useGlobalNetworkConfig = true;
|
||||
[SerializeField] private NetworkConfig networkConfigAsset;
|
||||
// Network configuration loaded from NetworkConfig.Instance
|
||||
|
||||
[Header("Audio Settings")]
|
||||
[SerializeField] private int recordingFrequency = 16000;
|
||||
@ -46,6 +43,8 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
|
||||
private UdpClient _udpClient;
|
||||
private IPEndPoint _targetEndPoint;
|
||||
private string targetIP;
|
||||
private int targetPort;
|
||||
private AudioClip _audioClip;
|
||||
private bool _isRecording = false;
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
@ -83,16 +82,20 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Apply global config if enabled
|
||||
if (useGlobalNetworkConfig)
|
||||
// Get network config from global instance
|
||||
var cfg = NetworkConfig.Instance;
|
||||
if (cfg != null)
|
||||
{
|
||||
var cfg = networkConfigAsset != null ? networkConfigAsset : NetworkConfig.Instance;
|
||||
if (cfg != null)
|
||||
{
|
||||
targetIP = cfg.ipAddress;
|
||||
targetPort = cfg.multiplayerAudioPort;
|
||||
}
|
||||
targetIP = cfg.ipAddress;
|
||||
targetPort = cfg.port;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("NetworkConfig not found! Please ensure NetworkConfig.asset exists in Resources folder.");
|
||||
targetIP = "255.255.255.255";
|
||||
targetPort = 1221;
|
||||
}
|
||||
|
||||
InitializeNetwork();
|
||||
InitializeAudio();
|
||||
_persistentDataPath = Application.persistentDataPath;
|
||||
|
||||
@ -17,10 +17,7 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
public class ConvaiUDPSpeechReceiver : MonoBehaviour
|
||||
{
|
||||
[Header("Network Configuration")]
|
||||
[SerializeField] private int listenPort = 12346;
|
||||
[SerializeField] private bool enableDebugLogging = true;
|
||||
[SerializeField] private bool useGlobalNetworkConfig = true;
|
||||
[SerializeField] private NetworkConfig networkConfigAsset;
|
||||
|
||||
[Header("Audio Playback")]
|
||||
[SerializeField] private AudioSource speechAudioSource;
|
||||
@ -35,6 +32,7 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
private UdpClient _udpListener;
|
||||
private IPEndPoint _remoteEndPoint;
|
||||
private bool _isListening = false;
|
||||
private int listenPort;
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
// Audio reconstruction
|
||||
@ -107,15 +105,19 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
private void Start()
|
||||
{
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
// Apply global config if enabled
|
||||
if (useGlobalNetworkConfig)
|
||||
|
||||
// Get network config from global instance
|
||||
var cfg = NetworkConfig.Instance;
|
||||
if (cfg != null)
|
||||
{
|
||||
var cfg = networkConfigAsset != null ? networkConfigAsset : NetworkConfig.Instance;
|
||||
if (cfg != null)
|
||||
{
|
||||
listenPort = cfg.multiplayerSpeechPort;
|
||||
}
|
||||
listenPort = cfg.port;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("NetworkConfig not found! Please ensure NetworkConfig.asset exists in Resources folder.");
|
||||
listenPort = 1221;
|
||||
}
|
||||
|
||||
InitializeAudio();
|
||||
InitializeNetwork();
|
||||
}
|
||||
|
||||
@ -18,11 +18,7 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
public class ConvaiUDPSpeechSender : MonoBehaviour
|
||||
{
|
||||
[Header("Network Configuration")]
|
||||
[SerializeField] private string targetIP = "127.0.0.1";
|
||||
[SerializeField] private int targetPort = 12346;
|
||||
[SerializeField] private bool enableDebugLogging = true;
|
||||
[SerializeField] private bool useGlobalNetworkConfig = true;
|
||||
[SerializeField] private NetworkConfig networkConfigAsset;
|
||||
|
||||
[Header("NPC Source")]
|
||||
[SerializeField] private bool useActiveNPC = true;
|
||||
@ -35,6 +31,8 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
// Network components
|
||||
private UdpClient _udpClient;
|
||||
private IPEndPoint _targetEndPoint;
|
||||
private string targetIP;
|
||||
private int targetPort;
|
||||
private bool _isInitialized = false;
|
||||
|
||||
// Speech tracking
|
||||
@ -55,16 +53,20 @@ namespace Convai.Scripts.Runtime.Multiplayer
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Apply global config if enabled
|
||||
if (useGlobalNetworkConfig)
|
||||
// Get network config from global instance
|
||||
var cfg = NetworkConfig.Instance;
|
||||
if (cfg != null)
|
||||
{
|
||||
var cfg = networkConfigAsset != null ? networkConfigAsset : NetworkConfig.Instance;
|
||||
if (cfg != null)
|
||||
{
|
||||
targetIP = cfg.ipAddress;
|
||||
targetPort = cfg.multiplayerSpeechPort;
|
||||
}
|
||||
targetIP = cfg.ipAddress;
|
||||
targetPort = cfg.port;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("NetworkConfig not found! Please ensure NetworkConfig.asset exists in Resources folder.");
|
||||
targetIP = "255.255.255.255";
|
||||
targetPort = 1221;
|
||||
}
|
||||
|
||||
InitializeNetwork();
|
||||
InitializeConvai();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user