We appreciate you sharing! Feel free to add this to the wiki as well.<div>-MC<br><br><div class="gmail_quote">On Fri, Feb 18, 2011 at 8:25 AM, Stephen Wilde <span dir="ltr">&lt;<a href="mailto:wstephen80@gmail.com">wstephen80@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I&#39;m learning to use ESL in C++ to do a call control and I want to share my code with the community.<div><br><div>I had a little difficult at startup so I hope that this code can help someone.</div>
<div><br></div><div>The code is: <a href="http://pastebin.freeswitch.org/15418" target="_blank">http://pastebin.freeswitch.org/15418</a></div>
<div><br></div><div>Using &quot;esl_oop&quot; module, I have implemented a basic ESL Channel class (that can be extended) so the &quot;main&quot; event handling loop can be very simple, for example for an unuseful esl bridge application, can be:</div>

<div><br></div><div>    ESLchannel legA(&amp;connection, inbound_uuid);</div><div><br></div><div>    ESLchannel legB(&amp;connection);</div><div>    legB.Originate(dialstring)</div><div><br></div><div>    while (1)</div>
<div>
    {</div><div><div>        ESLevent * event = connection.recvEventTimed(1000);</div><div><br></div><div>        if (event)</div><div>        {</div><div>            const char * ename = event-&gt;getHeader(&quot;Event-Name&quot;);</div>

<div>            const char * event_uuid = event-&gt;getHeader(&quot;unique-id&quot;);</div><div><br></div><div>            // It&#39;s an event for LegB ?</div><div>            //-------------------------</div><div>            if (legB.Uuid() == event_uuid)</div>

<div>            {</div><div>                if (!strcmp(ename, &quot;CHANNEL_PROGRESS_MEDIA&quot;))</div><div>                {</div><div>                    legA.PreAnswer();</div><div>                    legA.BridgeTo(legB);</div>

<div>                }</div><div>                else if (!strcmp(ename, &quot;CHANNEL_ANSWER&quot;))</div><div>                {</div><div>                    legA.Answer();</div><div>                    legA.BridgeTo(legB);</div>

<div>                }</div><div>                else if (!strcmp(ename,&quot;CHANNEL_HANGUP&quot;))</div><div>                {</div><div>                    const char * cause = event-&gt;getHeader(&quot;Hangup-Cause&quot;);</div>

<div><br></div><div>                    legA.Hangup(cause);</div><div>                }</div><div>            }</div><div>            // It&#39;s an event for LegA ?</div><div>            //-------------------------</div>

<div>            else if (legA.Uuid() == event_uuid)</div><div>            {</div><div>                if (!strcmp(ename,&quot;CHANNEL_HANGUP&quot;))</div><div>                {</div><div>                    const char * cause = event-&gt;getHeader(&quot;Hangup-Cause&quot;);</div>

<div><br></div><div>                    legB.Hangup(cause);</div><div>                }</div><div>            }</div><div><br></div><div>            delete event;</div><div>        }</div></div></div><div>    }</div>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div>