RoutableResourceRouteHalf Method (RoutableResource) |
Namespace: VoiceElements.Client
Routable Resource
This is the Routable Resource to which you would like to route. The resource from which you call this method becomes the first one in the route that is listening, the one specified by this parameter is the target or second in the route and does not listen.Exception | Condition |
---|---|
Exception |
public static void RouteHalfForListening() { TelephonyServer m_TelephonyServer = new TelephonyServer();// To get a channel, you must first get a link to a Telephony Server. You may need to pass a username password here. ChannelResource m_OutboundChannelResource1 = m_TelephonyServer.GetChannel();// Get first channel resource from the server ChannelResource m_OutboundChannelResource2 = m_TelephonyServer.GetChannel();// Get second channel resource from the server try { // Dial an outbound number with the first channel m_OutboundChannelResource1.Dial("4155551212"); // Assign a Voice Resource for playing VoiceResource m_VoiceResource = m_OutboundChannelResource1.VoiceResource; // In this case, we will not look atg dial result for simplicity and only route the two together // They will hear each other dial and ring m_OutboundChannelResource1.RouteFull(m_OutboundChannelResource2); // Route them together so m_OutboundChannelResource1 can hear the ringing m_OutboundChannelResource1.RouteFull(m_OutboundChannelResource2); // Dial an outbound number with the second channel DialResult dr = m_OutboundChannelResource2.Dial("2135551212"); if(dr == DialResult.Connected) { // Unroute so they can't hear each other m_OutboundChannelResource1.StopListener(m_OutboundChannelResource2); // Route them to the same Voice Resource so you can play your message m_OutboundChannelResource1.RouteHalf(m_VoiceResource); m_OutboundChannelResource2.RouteHalf(m_VoiceResource); m_VoiceResource.PlayTTS("This call has been sponsored by Inventive Labs, enjoy your conversation"); // now let them speak to each other. m_OutboundChannelResource1.RouteFull(m_OutboundChannelResource2); // *** Insert a loop to wait for a hangup or other event here while the two parties are talking } } finally { // Once the call is complete, you should clear out the routes using the StopListener first to stop any channel listening to this one. m_OutboundChannelResource1.StopListener(m_OutboundChannelResource2); m_OutboundChannelResource2.StopListener(m_OutboundChannelResource1); // Then route each channel back to their dedicated voice resource to ensure they can be played to successfully m_OutboundChannelResource1.RouteFull(m_OutboundChannelResource1.VoiceResource); m_OutboundChannelResource2.RouteFull(m_OutboundChannelResource2.VoiceResource); } }