1

Can I take billsec or duration of originated call from response event? I need originated calls final data.

OriginateAction originateAction = new OriginateAction();
originateAction.setChannel("SIP/xxxxxx");
originateAction.setContext("xxxxx");
originateAction.setExten("xxxxx");
originateAction.setCallerId("xxxxx");
originateAction.setAsync(Boolean.TRUE);
originateAction.setPriority(1);

managerConnection.sendAction(new StatusAction());
ManagerResponse mr = managerConnection.sendAction(originateAction);
//ResponseEvents mr = managerConnection.sendEventGeneratingAction(originateAction);
System.out.println(mr.getResponse());

int billsec = ???
Mike Laren
  • 8,028
  • 17
  • 51
  • 70
cagdas
  • 107
  • 1
  • 7
  • possible duplicate of http://stackoverflow.com/questions/1770010/how-do-i-measure-time-elapsed-in-java ? (`System.nanoTime()` ;) – xerx593 Apr 24 '15 at 11:56
  • 1
    No I want originated call's billsec, its about asterisk-java library. – cagdas Apr 24 '15 at 12:07

2 Answers2

0

You need mark CDR(userfield) or CDR(accountcode) in dialplan

After that you can collect cdr in mysql or other database on your request.

arheops
  • 15,544
  • 1
  • 21
  • 27
  • 1
    Is there any solution on java side for this problem? Such as eventlistener? – cagdas Apr 24 '15 at 12:34
  • Yes, you can put in dialplan UserEvent command and listen for it on java. But that is usless, simple just check mysql table,no? – arheops Apr 24 '15 at 16:12
0

No, once a call had been originated via the manager, the control is at the Asterisk dialplan - no longer with your JAVA program. In order to extract that information, you will need to add a proper handler to your "h" extension, within the dialplan. Depending on the DIALSTATUS, it will give you access to the DIALEDTIME and ANSWEREDTIME variables, which will contain the information you are seeking.