<div dir="ltr"><div><div><div>Greeting,<br><br></div>bellow is an example to handle outbound connection and make hung up:<br><br></div>but it never show How to make the connection in first place<br><br></div>is their an example in main of how this function work ?<br>
<div><div><div><div><div><div><br>/*<br> * Copyright 2010 david varnes.<br> *<br> * Licensed under the Apache License, version 2.0 (the &quot;License&quot;); <br> * you may not use this file except in compliance with the License. <br>
 * You may obtain a copy of the License at:<br> *<br> *    <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a><br> *<br> * Unless required by applicable law or agreed to in writing, software<br>
 * distributed under the License is distributed on an &quot;AS IS&quot; BASIS, <br> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> * See the License for the specific language governing permissions and<br>
 * limitations under the License.<br> */<br>package org.freeswitch.esl.client.outbound.example;<br><br>import org.freeswitch.esl.client.outbound.AbstractOutboundClientHandler;<br>import org.freeswitch.esl.client.transport.SendMsg;<br>
import org.freeswitch.esl.client.transport.event.EslEvent;<br>import org.freeswitch.esl.client.transport.message.EslMessage;<br>import <a href="http://org.freeswitch.esl.client.transport.message.EslHeaders.Name">org.freeswitch.esl.client.transport.message.EslHeaders.Name</a>;<br>
import org.jboss.netty.channel.Channel;<br>import org.jboss.netty.channel.ChannelHandlerContext;<br><br>/**<br> * Simple example of a handler for outbound connection from FreeSWITCH server.<br> * This class will log some of the FreeSWTICH call channel variables and <br>
 * then hangup the call.  <br> * <br> * @author  david varnes<br> */<br>public class SimpleHangupOutboundHandler extends AbstractOutboundClientHandler<br>{<br>    <br>    @Override<br>    protected void handleConnectResponse( ChannelHandlerContext ctx, EslEvent event )<br>
    {<br>        <a href="http://log.info">log.info</a>( &quot;Received connect response [{}]&quot;, event );<br>        if ( event.getEventName().equalsIgnoreCase( &quot;CHANNEL_DATA&quot; ) )<br>        {<br>            // this is the response to the initial connect <br>
            <a href="http://log.info">log.info</a>( &quot;=======================  incoming channel data  =============================&quot; );<br>            <a href="http://log.info">log.info</a>( &quot;Event-Date-Local: [{}]&quot;, event.getEventDateLocal() );<br>
            <a href="http://log.info">log.info</a>( &quot;Unique-ID: [{}]&quot;, event.getEventHeaders().get( &quot;Unique-ID&quot; ) );<br>            <a href="http://log.info">log.info</a>( &quot;Channel-ANI: [{}]&quot;, event.getEventHeaders().get( &quot;Channel-ANI&quot; ) );<br>
            <a href="http://log.info">log.info</a>( &quot;Answer-State: [{}]&quot;, event.getEventHeaders().get( &quot;Answer-State&quot; ) );<br>            <a href="http://log.info">log.info</a>( &quot;Caller-Destination-Number: [{}]&quot;, event.getEventHeaders().get( &quot;Caller-Destination-Number&quot; ) );<br>
            <a href="http://log.info">log.info</a>( &quot;=======================  = = = = = = = = = = =  =============================&quot; );<br>            <br>            // now hangup the call<br>            hangupCall( ctx.getChannel() );<br>
        }<br>        else<br>        {<br>            throw new IllegalStateException( &quot;Unexpected event after connect: [&quot; + event.getEventName() + &#39;]&#39; );<br>        }<br>    }<br><br>    @Override<br>    protected void handleEslEvent( ChannelHandlerContext ctx, EslEvent event )<br>
    {<br>        <a href="http://log.info">log.info</a>( &quot;Received event [{}]&quot;, event );<br>    }<br>    <br>    private void hangupCall( Channel channel )<br>    {<br>        SendMsg hangupMsg = new SendMsg();<br>
        hangupMsg.addCallCommand( &quot;execute&quot; );<br>        hangupMsg.addExecuteAppName( &quot;hangup&quot; );<br>        <br>        EslMessage response = sendSyncMultiLineCommand( channel, hangupMsg.getMsgLines() );<br>
        <br>        if ( response.getHeaderValue( Name.REPLY_TEXT ).startsWith( &quot;+OK&quot; ) )<br>        {<br>            <a href="http://log.info">log.info</a>( &quot;Call hangup successful&quot; );<br>        }<br>
        else<br>        {<br>            log.error( &quot;Call hangup failed: [{}}&quot;, response.getHeaderValue( Name.REPLY_TEXT ) );<br>        }<br>    }<br>}<br><br></div></div></div></div></div></div></div>