Re: [Asterisk-java-users] Listen for an incomming call to a sip/extension
Brought to you by:
srt
From: Wayne M. <way...@th...> - 2014-04-14 15:37:28
|
Hi, Normally you would loop through the channels until you find the extension you're looking at with channel.getCallerId().getNumber() Then you can see if it is linked with another channel by channel.getLinkedChannel() and get the caller id from that in the same way. If you're doing this in "real time", the way I do it is to register an AsteriskServerListener and then for every new channel add a PropertyChangeListener You then need to figure out what type of events you want to listen to and which ones to ignore (hint you get a lot of events). To help you narrow it down most likely all you need are the following: public void propertyChange(PropertyChangeEvent evt){ if(evt.getPropertyName().equals("state") && evt.getSource() instanceof AsteriskChannel){ if(evt.getNewValue() instanceof ChannelState){ ChannelState state = (ChannelState)evt.getNewValue(); //Then look at state.getStatus() for things like RING or RINGING or HUNGUP or BUSY //You can get the channel in question by doing evt.getSource() }else if(evt.getPropertyName().equals("currentExtension") && evt.getOldValue() == null){ //The evt.getNewValue() here will have an Extension object which you can use to see what this channel is ringing //Note you get a lot of dialplan messages here that you can skip, they're usually with a context of macro-auto-blkvm //but this varies depending on what Asterisk system you use }else if(evt.getPropertyName().equals("linkedChannel") && evt.getSource() instanceof AsteriskChannel){ //You get these when two channels connect to each other e.g. when someone picks up a call //You will get at least two of these for both sides of the call } } } Hope this gets you started, Wayne Merricks The Voice Asia On 14/04/14 14:15, Jorge wrote: > How can I get from this event the phone that is callling this extension? > > I am looking in to asteriskServer.getChannels(); but the channel is > not created when the status changed. > > Jorge > > ---------------------------------------------------------------------------------------------------------------------------------------------- > > > <https://twitter.com/#%21/correderajorge> <http://www.correderajorge.es/> > > En función de la /Ley Orgánica 15/1999/, este mensaje de correo > electrónico y sus documentos adjuntos están dirigidos > /exclusivamente/ a los destinatarios especificados y su información es > de uso /estrictamente privado/ salvo que se especifique lo contrario. > La información contenida puede ser /confidencial/ y/o estar > /legalmente protegida/. Si usted recibe este mensaje por /error/, por > favor comuníqueselo inmediatamente al remitente y /elimínelo/ ya que > carece de autorización de todo tipo. /Se prohíbe expresamente/ la > revelación, distribución, impresión o copia de toda o alguna parte de > la información contenida en este mensaje > > > > 2014-04-13 11:03 GMT+02:00 Miguel Santiago <m.s...@gm... > <mailto:m.s...@gm...>>: > > I think you can Use ExtensionStatusEvent in order to know what you > need > > El 10/04/2014 20:57, "Jorge" <gus...@gm... > <mailto:gus...@gm...>> escribió: > > Hi: > > I would like to know if it is possible to implement a listener > or check if a sip extension is busy with a call. And in case > it is answering a call how to know which number is calling. > > Kind Regards > > Jorge > > > ------------------------------------------------------------------------------ > Put Bad Developers to Shame > Dominate Development with Jenkins Continuous Integration > Continuously Automate Build, Test & Deployment > Start a new project now. Try Jenkins in the cloud. > http://p.sf.net/sfu/13600_Cloudbees > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > <mailto:Ast...@li...> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > ------------------------------------------------------------------------------ > Put Bad Developers to Shame > Dominate Development with Jenkins Continuous Integration > Continuously Automate Build, Test & Deployment > Start a new project now. Try Jenkins in the cloud. > http://p.sf.net/sfu/13600_Cloudbees > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > <mailto:Ast...@li...> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > > ------------------------------------------------------------------------------ > Learn Graph Databases - Download FREE O'Reilly Book > "Graph Databases" is the definitive new guide to graph databases and their > applications. Written by three acclaimed leaders in the field, > this first edition is now available. Download your free book today! > http://p.sf.net/sfu/NeoTech > > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |