[Asterisk-java-users] using originateToExtensionAsync, addPropertyChangeListener and a "Local/" cha
Brought to you by:
srt
From: Richard H. <ri...@ha...> - 2008-06-06 17:02:51
|
Hi there, I'm originating a call from a Local channel using originateToExtensionAsync. I add a propertyChangeListener, for which i want to get the CallDetailRecords for both legs of the call and output the billableSeconds. However, with the current code below, the second leg (we'll call this the company leg)'s CDR is always null. I would appreciate any help to try to figure out why it is not creating a CDR for this event. Thanks in advance Richard public static void main(String[] agrs) throws InterruptedException, ManagerCommunicationException, NoSuchChannelException { ManagerConnectionFactory mcf = new ManagerConnectionFactory("ip","user","pass"); AsteriskServerImpl as = new AsteriskServerImpl(mcf.createManagerConnection()); as.initialize(); OriginateCallback ocb = new OriginateCallbackTest(); as.originateToExtensionAsync("Local/3"+ clientNumber + "@myContext/n", "myContext", compNumber, 1, 15000L, ocb); } public class OriginateCallbackTest implements OriginateCallback{ private AsteriskChannel clientChannel = null; private AsteriskChannel compChannel= null; public void onBusy(AsteriskChannel arg0) { } public void onDialing(AsteriskChannel arg0) { } public void onFailure(LiveException arg0) { } public void onNoAnswer(AsteriskChannel arg0) { } public void onSuccess(AsteriskChannel chan) { clientChannel = chan; chan.addPropertyChangeListener(new PropertyChangeListener(){ public void propertyChange(PropertyChangeEvent evt) { if(evt.getNewValue()!=null) System.out.println("++++++++ THE VALUE NOW IS " + evt.getNewValue().toString()); System.out.println("++++++++ THE PROPERTY NAME IS " + evt.getPropertyName()); if(evt.getSource() instanceof AsteriskChannel) { /* * This is an event that happened on the clientChannel */ if(evt.getSource() == clientChannel) { AsteriskChannel client = (AsteriskChannel)evt.getSource(); AsteriskChannel comp = client.getDialedChannel(); CallDetailRecord clientCdr = client.getCallDetailRecord(); CallDetailRecord compCdr = comp.getCallDetailRecord(); if(clientCdr!=null){ System.out.println("+++++++++++++ Client CDR billable seconds is " + clientCdr.getBillableSeconds()); }else{ System.out.println("+++++++++++++ CDR for client was null"); } if(comp !=null) { if(compCdr != null){ System.out.println("+++++++++++++ Company CDR billable seconds is " + comp.getCallDetailRecord().getBillableSeconds()); }else{ System.out.println("+++++++++++++ CDR for company was null"); } } } } } }); } } |