I just started poking around with writing a python module to interface to the Manager API, and it suddenly hit me... how the heck are you supposed to program this thing? All the events seem to be dumped to all the open connections. If I send a command, such as a login, there seems to me to be no way to determine which response are intended for me, and which may be intended for another open session. There's no reference number, or anything which indicates who events are for. This would seem to make it pretty much impossible to program.... at all. Anyone done this??? Doug.
Douglas Garstang wrote:> I just started poking around with writing a python module to interface to the Manager API, and it suddenly hit me... how the heck are you supposed to program this thing? > > All the events seem to be dumped to all the open connections. If I send a command, such as a login, there seems to me to be no way to determine which response are intended for me, and which may be intended for another open session. There's no reference number, or anything which indicates who events are for. This would seem to make it pretty much impossible to program.... at all. > > Anyone done this??? > > Doug. >There's a Java packaged that contains numerous classes allowing you to interact with Asterisk. It interacts via the FastAGI protocol as well as the Asterisk Manager API. Check it out at http://asterisk-java.sourceforge.net/ Flynn
Yikes. Java. Yuck. I'll stick with Python... Thanks anyway. I just worked it out... you can supply an actionid to the request to know what reply to look for, although it will still be tricky filtering out the noise. Doug. -----Original Message----- From: El Flynn [mailto:el_flynn@lanvik-icu.com] Sent: Tue 3/21/2006 10:05 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Cc: Subject: Re: [Asterisk-Users] Programming the Manager API Douglas Garstang wrote: > I just started poking around with writing a python module to interface to the Manager API, and it suddenly hit me... how the heck are you supposed to program this thing? > > All the events seem to be dumped to all the open connections. If I send a command, such as a login, there seems to me to be no way to determine which response are intended for me, and which may be intended for another open session. There's no reference number, or anything which indicates who events are for. This would seem to make it pretty much impossible to program.... at all. > > Anyone done this??? > > Doug. > There's a Java packaged that contains numerous classes allowing you to interact with Asterisk. It interacts via the FastAGI protocol as well as the Asterisk Manager API. Check it out at http://asterisk-java.sourceforge.net/ Flynn _______________________________________________ --Bandwidth and Colocation provided by Easynews.com -- Asterisk-Users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/ms-tnef Size: 5114 bytes Desc: not available Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20060321/7426536b/attachment.bin
That's way too much Java for me. I'm lost already. -----Original Message----- From: El Flynn [mailto:el_flynn@lanvik-icu.com] Sent: Tue 3/21/2006 10:20 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Cc: Subject: Re: [Asterisk-Users] Programming the Manager API Douglas Garstang wrote: > Yikes. Java. Yuck. I'll stick with Python... Thanks anyway. > I just worked it out... you can supply an actionid to the request to know what reply to look for, although it will still be tricky filtering out the noise. > Well, with the Asterisk java code it's pretty much cut and dried. Take a look at some of the examples and you'll be surprised how quickly you can come up with a workable app. It's as easy as: if (event instanceof NewChannelEvent) { /* Change icon color from green to red */ } else if (event instanceof HangupEvent) { /* Change the icon color from red to green */ } The filtering bit is "kind of" done for you there so you won't have to muck around with parsing what is thrown back at you by *. Although you might want to download the source code and see how that parsing is done. Flynn _______________________________________________ --Bandwidth and Colocation provided by Easynews.com -- Asterisk-Users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
> That's way too much Java for me. I'm lost already. >Doug, I'm a Perl guy myself, so I think in terms of Perl and CPAN. I'm sure Python has its own version of CPAN where people upload modules for other programmers to use. CPAN has a Perl module: POE::Component::Client::Asterisk::Manager It's an encapsulation layer using POE (Perl Object Environment - an easy way to do real event-based programming in Perl). Does Python have something similar? I know Python is way heavy on OOP and OOP is great for event-based programming. Just curious if someone out there might have already solved this problem and created a Python module that you could borrow... -MC