Janahan Vivekanandan
2006-Aug-14 01:44 UTC
[asterisk-users] Associating an Originate Request to a Channel before the call is answered
Hi, I'm trying to figure out how to cancel a call before the other side answers. It looks like I can do this by issueing a HangUp Action using the ChannelId that asterisk initiates the call on. Unfortunately, I don't know of a way to associate the NewChannel Event which contains the ChannelId, to the Originate Action. I'm using the Async mode of the Originate Action, and it looks like the UniqueID in the Response to the Originate Action is null. I know that I can use the ActionID to accomplish this once I receive the OriginateSuccess event, but I need to be able to cancel the call before it is answered(I'm pretty sure OriginateSuccess is only sent after the call is answered, correct me if I'm wrong...:-) thanks bunch. -janahan
Stefan Reuter
2006-Aug-14 02:52 UTC
[asterisk-users] Associating an Originate Request to a Channel before the call is answered
Janahan Vivekanandan wrote:> I know that I can use the ActionID to accomplish this once I receive > the OriginateSuccess event, but I need to be able to cancel the call > before it is answered(I'm pretty sure OriginateSuccess is only sent > after the call is answered, correct me if I'm wrong...:-)You are right and the canonical answer seems to be you can't. I had the same problem a few weeks ago for the development of Asterisk-Java and solved it by setting a channel variable in the Originate action which I check for with every NewChannel event. Not nice, but it a working hack. =Stefan -- reuter network consulting Neusser Str. 110 50760 Koeln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: srt@reucon.net -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 271 bytes Desc: OpenPGP digital signature Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20060814/4cf58656/signature.pgp
Tony Mountifield
2006-Aug-14 02:57 UTC
[asterisk-users] Re: Associating an Originate Request to a Channel before the call is answered
In article <20060814084404.23407.qmail@web80402.mail.yahoo.com>, Janahan Vivekanandan <janahanv@yahoo.com> wrote:> Hi, > > I'm trying to figure out how to cancel a call before the other side answers. > > It looks like I can do this by issueing a HangUp Action using the ChannelId that asterisk > initiates the call on. Unfortunately, I don't know of a way to associate the NewChannel > Event which contains the ChannelId, to the Originate Action. I'm using the Async mode of the > Originate Action, and it looks like the UniqueID in the Response to the Originate Action is > null. > > I know that I can use the ActionID to accomplish this once I receive the OriginateSuccess > event, but I need to be able to cancel the call before it is answered(I'm pretty sure > OriginateSuccess is only sent after the call is answered, correct me if I'm wrong...:-)I don't know whether the ActionID gets propagated to the new channel in SVN trunk, but that would be a good enhancement. Apart from that, the only way I have found to do it is to use a Local channel for the outgiong call, to encode a serial number in the extension part of the channel, and strip it out in the dialplan before dialling the number. e.g. Action: Originate Channel: Local/123-0987654321@outgoing etc. Where 123 is a unique serial number and 0987654321 is the number to dial. Then in extensions.conf, context [outgoing], use CUT() to discard the serial number and call Dial with the actual phone number. When you see the Newchannel event for Local/123-0987654321@outgoing-xxxx,2 you can match it on the prefix part and associate it with the Originate. The serial number doesn't need to get used anywhere - it is just to make sure that every channel identifier is unique. You will have to make sure you correctly track Rename, Link and Unlink events, since Local channels optimise themselves out when the call is set up. Hope this helps! Cheers Tony -- Tony Mountifield Work: tony@softins.co.uk - http://www.softins.co.uk Play: tony@mountifield.org - http://tony.mountifield.org