private static void HandleDirectMode(string callWavPath, string callJsonPath = null, CancellationToken cancellationToken = default(CancellationToken)) { var callHandler = new CallHandler(_liquidConfig); callHandler.HandleCallAsync(callWavPath, callJsonPath, _cancellationTokenSource.Token) .GetAwaiter() .GetResult(); }
private static void HandleServerMode() { var callHandler = new CallHandler(_liquidConfig); using (var socket = new UdpSocket()) { try { socket.Server(_liquidConfig.UdpServerIpAddress, _liquidConfig.UdpServerPort, async(msg) => { Console.WriteLine("LiquidBridge (Server) RECV: {0}", msg); var parts = msg.Split('|', 2, StringSplitOptions.RemoveEmptyEntries); var callWavPath = string.Empty; var callJsonPath = string.Empty; if (parts.Length > 0) { callWavPath = parts[0]; if (parts.Length > 1) { callJsonPath = parts[1]; } } await callHandler.HandleCallAsync(callWavPath, callJsonPath, _cancellationTokenSource.Token); }); while (!_cancellationTokenSource.IsCancellationRequested) { Task.Delay(200).Wait(_cancellationTokenSource.Token); } } finally { _cancellationTokenSource.Cancel(); } } Console.WriteLine("Press Enter to Exit"); Console.ReadLine(); }