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"><<a href="mailto:wstephen80@gmail.com">wstephen80@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I'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 "esl_oop" module, I have implemented a basic ESL Channel class (that can be extended) so the "main" event handling loop can be very simple, for example for an unuseful esl bridge application, can be:</div>
<div><br></div><div> ESLchannel legA(&connection, inbound_uuid);</div><div><br></div><div> ESLchannel legB(&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->getHeader("Event-Name");</div>
<div> const char * event_uuid = event->getHeader("unique-id");</div><div><br></div><div> // It's an event for LegB ?</div><div> //-------------------------</div><div> if (legB.Uuid() == event_uuid)</div>
<div> {</div><div> if (!strcmp(ename, "CHANNEL_PROGRESS_MEDIA"))</div><div> {</div><div> legA.PreAnswer();</div><div> legA.BridgeTo(legB);</div>
<div> }</div><div> else if (!strcmp(ename, "CHANNEL_ANSWER"))</div><div> {</div><div> legA.Answer();</div><div> legA.BridgeTo(legB);</div>
<div> }</div><div> else if (!strcmp(ename,"CHANNEL_HANGUP"))</div><div> {</div><div> const char * cause = event->getHeader("Hangup-Cause");</div>
<div><br></div><div> legA.Hangup(cause);</div><div> }</div><div> }</div><div> // It's an event for LegA ?</div><div> //-------------------------</div>
<div> else if (legA.Uuid() == event_uuid)</div><div> {</div><div> if (!strcmp(ename,"CHANNEL_HANGUP"))</div><div> {</div><div> const char * cause = event->getHeader("Hangup-Cause");</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>