如何在VB.NET中获得出站Twilio呼叫的最终状态?

时间:2019-03-20 19:27:53

标签: .net twilio

我有一个正在生成呼叫的.NET控制台应用程序,我需要根据是否已应答呼叫来采取措施。通话成功,我在测试手机上接听电话,并且听到xml文件中的语音。但是,CallResource对象的状态始终为“排队”。获得通话最终状态的正确方法是什么?

代码:

.bg-blue {
}
.signout-button {
  border-radius: 10px;
  color: white !important;
  background-color: #183450;
  border-color: #183450;
  border-style: solid;
}

1 个答案:

答案 0 :(得分:1)

我发现一种可行的方法:

Dim phonecall = CallResource.Create([to]:=New Types.PhoneNumber(oncallnumber), from:=New Types.PhoneNumber(twilionumber), url:=New Uri(oncallmessagefile), method:="get")
Dim sid As String = phonecall.Sid
Dim OnCallStatus As CallResource.StatusEnum

'' wait until the call is successful, not answered, or fails
Do
    OnCallStatus = CallResource.Fetch(sid).Status
    Debug.WriteLine(Now() & " - " & OnCallStatus.ToString)
    System.Threading.Thread.Sleep(1000)
Loop Until OnCallStatus = CallResource.StatusEnum.NoAnswer Or OnCallStatus = CallResource.StatusEnum.Completed Or OnCallStatus = CallResource.StatusEnum.Failed