Click or drag to resize

RoutableResourceRouteHalf Method (RoutableResource)

Completes a half route between two Routable Resources. The channel calling this method listens to the one in the parameter, the second cannot hear.

Namespace:  VoiceElements.Client
Assembly:  VoiceElementsClient (in VoiceElementsClient.dll) Version: 8.6.1.1
Syntax
public void RouteHalf(
	RoutableResource routableResource
)

Parameters

routableResource
Type: VoiceElements.ClientRoutableResource

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.
Exceptions
ExceptionCondition
Exception
Remarks
The Route Half method routes the transmit timeslot of the firstg resource to the second. This will allow a Routable Resource to listen to another resource. It will not allow the other resource to listen to the first resource.

Routing Resources - When to Use It

This method is used to allow a caller or a resource to listen when you would like the other muted. Be careful to recognize which you would like to hear and when you should have both listen and do a Full Route.

Full Route vs Half Route

A Full Route allows both parties to listen to each other, while a Half Route will only allow one party to listen to the other. This distinction should be decided in each case you want to do a route.

Examples
The example below shows how to route two resources together in a hlf route. This simple code gets two Channel Resources, then executes a Dial Method on each to place two separate outbound calls. The code then does a Stop Listener so the two channels cannot hear each other, the uses two half routes to have each of them listen to one Voice Resource so a Text to Speech Play can play a message to both, and then does a Full Route for the two channels to talk.
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);
    }
}
See Also