We appreciate you sharing! Feel free to add this to the wiki as well. -MC On Fri, Feb 18, 2011 at 8:25 AM, Stephen Wilde <wstephen80@gmail.com> wrote:
I'm learning to use ESL in C++ to do a call control and I want to share my code with the community.
I had a little difficult at startup so I hope that this code can help someone.
The code is: http://pastebin.freeswitch.org/15418
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:
ESLchannel legA(&connection, inbound_uuid);
ESLchannel legB(&connection); legB.Originate(dialstring)
while (1) { ESLevent * event = connection.recvEventTimed(1000);
if (event) { const char * ename = event->getHeader("Event-Name"); const char * event_uuid = event->getHeader("unique-id");
// It's an event for LegB ? //------------------------- if (legB.Uuid() == event_uuid) { if (!strcmp(ename, "CHANNEL_PROGRESS_MEDIA")) { legA.PreAnswer(); legA.BridgeTo(legB); } else if (!strcmp(ename, "CHANNEL_ANSWER")) { legA.Answer(); legA.BridgeTo(legB); } else if (!strcmp(ename,"CHANNEL_HANGUP")) { const char * cause = event->getHeader("Hangup-Cause");
legA.Hangup(cause); } } // It's an event for LegA ? //------------------------- else if (legA.Uuid() == event_uuid) { if (!strcmp(ename,"CHANNEL_HANGUP")) { const char * cause = event->getHeader("Hangup-Cause");
legB.Hangup(cause); } }
delete event; } }
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org