Re: [Asterisk-java-users] Transfer call to another extension
Brought to you by:
srt
From: Wayne M. <way...@th...> - 2015-01-15 23:56:15
|
Hi, I use the Live Manager API to do the following. I have an active channels HashMap which holds Channel objects. When I get a new channel I want to deal with, I add it to the active channels list. Then I have the following helper method: /** * Redirects the given channel to the given extension * @param channelID Channel to redirect * @param to extension to send channel to */ public void redirectCall(String channelID, String to){ AsteriskChannel channel = activeChannels.get(channelID); channel.redirect(autoAnswerContext, to, DEFAULT_PRIORITY); //autoAnswerContext is part of my dial plan that sets the auto answer flags //If you want to redirect to a queue use this instead //channel.redirect(defaultContext, queueNumber, DEFAULT_PRIORITY); } Which all seems straight forward enough, however you mentioned outgoing calls which gave me a problem too. I found the following weirdness to be true: If I create an outgoing call, I will get a couple of channels including an initial one for the party I'm calling. For some reason peculiar to queues, if I then transfer this party to a queue the initial channel ID I was holding gets dropped and a new channel is generated once the party is in the queue. At this stage the channel always remains the same no matter what you do to the party but this initial channel change confused the heck out of me. Hope this helps, for way more code than is here have a look through: https://github.com/waynemerricks/asteriskphone/blob/wip-work/src/com/thevoiceasia/phonebox/asterisk/AsteriskManager.java On 2015-01-15 20:45, Jorge wrote: > Hi, > > I am would like to use Asterisk-Java to transfer a call that is in a > queue. > > The context is the next one. One call go to a queue so I detect the > call with onNewQueueEntry and check if it goes to my queue. If it > goes > after doing several things I want to transfers it back to a > extension. > The main idea is detecting a call, doing things that can´t be done > through the dialplan and give it back to the dialplan. > > As entry.getChannel has the channel that is in the queue I wanted to > use this channel to transfer to the desired extension. I have done > several attemps but nothing worked. > > public void onNewQueueEntry(final AsteriskQueueEntry entry) { > // Si está en la cola que estamos monitorizando, > procesa > if(entry.getQueue().getName().equals(queueName)){ > > Dialplan > > [myCall] > exten => s,1,NoOp(myCall) > exten => s,n,Playback(es/digits/1) > exten => s,n,Return() > > 1) > Java-code > AtxferAction action = new > AtxferAction(entry.getChannel().getName(), "myCall", "s", 1); > ManagerResponse response = > Asterisk.getManagerConnection().sendAction(action); > > The answer is ok but nothing happens. > org.asteriskjava.manager.response.ManagerResponse: actionId=null; > message=Atxfer successfully queued; response=Success; uniqueId=null; > systemHashcode=1928471006 > > 2) OriginateAction dial = new > OriginateAction(); > // // Sets the name of the channel to > connect to the outgoing call. > > dial.setChannel(entry.getChannel().getName()); > > // Sets the name of the context of the > extension to connect to. > dial.setContext("myCall"); > // Sets the extension to connect to > dial.setExten("s"); > dial.setPriority(1); > ManagerResponse response = > Asterisk.getManagerConnection().sendAction(dial); > It gives me org.asteriskjava.live.NoSuchChannelException:Channel is > not available > > 3) > > Asterisk.getAsteriskServer().originateToApplication(entry.getChannel().getName()", > "myCall", "", 1000); > It gives me org.asteriskjava.live.NoSuchChannelException:Channel is > not available > > Could you let my know what I am doing wrong? > > Kind regards. |