CurrentCall Property

  Microsoft Speech Technologies Homepage

Gets the current active CallInfo object or null if no call is active. Read-only.

Usage

ASP.NET markup: <speech:SpeechControl CurrentCall="..." />
Get value: CallInfo = SpeechControl.CurrentCall;
Set value: Read-only
Data type: CallInfo
Required: No

Remarks

If no call is in progress, the CallInfo object that is returned contains null strings in its DeviceID, CallID, CallingDevice and CalledDevice properties.

All Speech Controls and Call Management Controls that derive from the SpeechControl class inherit the CurrentCall property.

Example

The following XML file and code example are adapted from the SASDK Speech Application Selector Page. Each node in this file references one of the SDK sample applications. Users open the Telephony Application Simulator application and enter the number of an SDK sample as if dialing it on a telephone keypad. The example code uses the CurrentCall property of the AnswerCall control to obtain the number entered by the user, selects the XML node with that number, extracts the name of the application page from that node, and redirects to that application page.

ApplicationsStartPageMappings.xml

<?xml version="1.0" encoding="utf-8" ?>
<StartPageMapping>
  <Sample Number="0" Path="Contacts/Default.aspx" />
  <Sample Number="1" Path="Samples/UserInputAndResults/Page1.aspx" />
  <Sample Number="2" Path="Samples/SilenceAndLowConf/Page1.aspx" />
  <Sample Number="3" Path="Samples/NaturalPromptOutput/Page1.aspx" />
  <Sample Number="4" Path="Samples/ConfirmationAndCorrection/Page1.aspx" />
  <Sample Number="5" Path="Samples/CommandsAndContextHelp/Page1.aspx" />
  <Sample Number="6" Path="Samples/UsingDTMF/Page1.aspx" />
  <Sample Number="7" Path="Samples/CentralizedSettings/Page1.aspx" />
  <Sample Number="8" Path="Samples/PageTransitionPrompt/Page1.aspx" />
  <Sample Number="9" Path="Samples/SelectingFromList/Page1.aspx" />
  <Sample Number="10" Path="Samples/PhoneNumber/Page1.aspx" />
  <Sample Number="11" Path="Samples/DatesAndValidation/Page1.aspx" />
  <Sample Number="12" Path="Samples/CreditCardInfo/CreditCardInfo.aspx" />
  <Sample Number="13" Path="Samples/TableNavigation/Page1.aspx" />
  <Sample Number="14" Path="Samples/ColorChooser/ChooseColor.aspx" />
</StartPageMapping>

<script runat="server" language="C#">
  void OnServerDelivered(object sender, EventArgs e)
  {
    AnswerCall  mcobj = (AnswerCall)sender;
    System.Xml.XmlNode theNode = null;
    try 
    {
      System.Xml.XmlDocument mappingList = new System.Xml.XmlDocument();
      string theFile = Page.MapPath("ApplicationsStartPageMappings.xml");
      if (System.IO.File.Exists(theFile) == false) 
        throw(new Exception(theFile + " does not exist"));
      mappingList.Load(theFile);
      theNode = mappingList.SelectSingleNode("/StartPageMapping/Sample[@Number=" + mcobj.CurrentCall.CalledDevice.ToString() + "]");
    } 
    catch (Exception ex) 
    {
      throw(new Exception("Failed to load StartPageMappings.xml", ex));
    }
    if (theNode != null) 
    {
      try 
      {
        string theUrl = theNode.Attributes["Path"].Value.ToString();
        AnswerCall1.Redirect(theUrl);
      }
      catch (Exception ex) 
      {
        throw(new Exception("Failed to find URL to redirect to", ex));
      }
    }
  }
</script>
<form id="Form1" method="post" runat="server">
  ...
  <speech:AnswerCall id="AnswerCall1" 
    autopostback="true"
    CallingDevice="0"
    OnDelivered="OnServerDelivered"
    runat="server" />
  <speech:DisconnectCall id="DisconnectCall1" 
    autopostback="false"
    runat="server" />
  ...
</form>

See Also

SpeechControl Class | SpeechControl Constructor | SpeechControl Members | SpeechControl Properties | SpeechControl Methods | SpeechControl Events