// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } // TODO call.Record RecordResult resultRecord = call.Record(new CallRecord { Audio = new CallRecord.AudioParams { // Default parameters } }); Logger.LogInformation("Recording {0} @ {1}", resultRecord.Successful ? "successful" : "unsuccessful", resultRecord.Url); HangupResult resultHangup = call.Hangup(); Successful = resultRecord.Successful && resultHangup.Successful; Completed.Set(); }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } PlayAction actionPlay = call.PlayTTSAsync("I'm a little teapot, short and stout. Here is my handle, here is my spout."); bool paused = false; while (!actionPlay.Completed) { paused = !paused; if (paused) { actionPlay.Pause(); } else { actionPlay.Resume(); } Thread.Sleep(3000); } HangupResult resultHangup = call.Hangup(); Successful = actionPlay.Result.Successful && resultHangup.Successful; Completed.Set(); }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } PromptResult resultPrompt = call.PromptTTS( "I'm a little teapot.", new CallCollect { Digits = new CallCollect.DigitsParams() { Max = 1 } }); HangupResult resultHangup = call.Hangup(); Successful = resultPrompt.Successful && resultHangup.Successful; Completed.Set(); }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } UdpClient udpClient = new UdpClient(RTPPort); TapAction actionTap = call.TapAsync( new CallTap { Type = CallTap.TapType.audio, Parameters = new CallTap.AudioParams { Direction = CallTap.AudioParams.AudioDirection.both, } }, new CallTapDevice { Type = CallTapDevice.DeviceType.rtp, Parameters = new CallTapDevice.RTPParams { Address = RTPAddr, Port = RTPPort, } } ); IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, RTPPort); byte[] data = udpClient.Receive(ref ipEndPoint); Task <UdpReceiveResult> resultReceive = udpClient.ReceiveAsync(); bool gotData = false; gotData = resultReceive.Wait(5000); if (gotData) { Logger.LogInformation("Received {0} RTP bytes", data.Length); } actionTap.Stop(); HangupResult resultHangup = call.Hangup(); Successful = gotData && actionTap.Result.Successful && resultHangup.Successful; Completed.Set(); }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } PlayResult resultPlay = call.PlayTTS("I'm a little teapot."); HangupResult resultHangup = call.Hangup(); Successful = resultPlay.Successful && resultHangup.Successful; Completed.Set(); }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } PromptAction actionPrompt = call.PromptTTSAsync( "I'm a little teapot, short and stout. Here is my handle, here is my spout.", new CallCollect { Digits = new CallCollect.DigitsParams() { Max = 1 } }); Thread.Sleep(5000); actionPrompt.Stop(); Logger.LogDebug("Waiting for prompt to complete"); while (!actionPrompt.Completed) { Thread.Sleep(500); } PlayResult resultPlay = call.PlayTTS("Stopped"); HangupResult resultHangup = call.Hangup(); Successful = resultPlay.Successful && resultHangup.Successful; Completed.Set(); }