Re: [Asterisk-java-users] Listen for an incomming call to a sip/extension
Brought to you by:
srt
From: Yves A. <yv...@gm...> - 2014-04-21 13:21:24
|
Hi, yes, you can use these events. To trace a call, especially take a look at: NewChannelEvent JoinEvent AgentCalledEvent QueueMemberStatusEvent DialEvent BridgeEvent NewStateEvent HangupEvent LeaveEvent To understand whats going on during a call (which is very dependent on your dialplan), just write an EventListener that prints out any event to a logfile / console and place a testcall (should be done on an asterisk that has nothing to do than serve your testcalls...) than analyze the output to see, which event is generated when and has which attributes... but again... things may vary between asterisk-versions and changes to your dialplan. A good way to get certain information at well defined points is to use UserEvents. You define them in your dialplan and if your listener catches UserEvents, you can reduce your coding as you serve the needed information yourself. yves Am 20.04.2014 10:32, schrieb Jorge: > I have just seen that it could be better to use Agents. > > http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/event/AgentsEvent.html > > I think I will implement as soon as possible and I will let you know. > > 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-20 10:00 GMT+02:00 Jorge <gus...@gm... > <mailto:gus...@gm...>>: > > Thank you for your answer. > > I want to implement a way to recognize incoming calls for sip > extensions that are waiting to incoming calls from telephone > network in a queue. That is to say I have n sip extensions in a > queue, so people call from outside the sip network to the queue. > From here Asterisk send the incoming call to one available sip > extension to the queue. I want to detect that the telephone with > number xxxxxx is calling to the sip extension Sip/xxx . > > Kind regards > > 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-16 22:22 GMT+02:00 Yves A. <yv...@gm... > <mailto:yv...@gm...>>: > > hi, > > the behaviour is very depending on your asterisk version and > dialplan. you could try to catch any bridge-event and keep > track of the sip extensions this way... but as always... > if you would describe your objective or why you are trying to > do what you do, I could go more in detail with help or > suggestions as there are sooooo many ways to get the > device or extension state. > > regards, > yves > > Am 16.04.2014 19:21, schrieb Jorge: >> Thank you for your help, but I still didn't it work. When I >> get the caller Id it is empty. >> >> My structure is the next one : >> I have n sip extensions inside a queue. When an incomming >> call gets inside it goes directly to the queue waitng for an >> available sip extension. What I am doing is attaching a >> listener to each new channel created. When I get >> evt.getPropertyName().equals("dialingExtension") I obtain the >> source and the dialing extension. >> As it comes from the pstn it creates an channel called >> dadhi/incomingTlfNumber@context this channel goes inside the >> queue and converts into something like Local/2501@queue.... . >> The main problem is that this channel Local/2501@queue... is >> automatically created with caller id empty when I detect the >> changing property (tested with asterisk-java) >> >> In conclusion I am able to get the channel FROM THE QUEUE >> that is calling the Sip extension but it has the caller id >> EMPTY. >> >> I am wirting my hearth so I could have wirtten some wrong >> labels. >> >> >> 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-14 17:45 GMT+02:00 Wayne Merricks >> <way...@th... >> <mailto:way...@th...>>: >> >> fyi messed up my else ifs they should be else if to the >> evt.getPropertyName() block not the ChannelState bit. >> >> Wayne Merricks >> The Voice Asia >> >> On 14/04/14 16:17, Wayne Merricks wrote: >>> 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... <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... <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... >> <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... <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... > <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 |