Re: [Asterisk-java-devel] Using asterisk-java (get a list of all extensions)
Brought to you by:
srt
From: Carlos G M. <tr...@ac...> - 2007-08-09 09:52:56
|
I guess there is no simple way. If you know all your extensions are of a kind (i.e. all SIP or IAX) you can use a CLI "sip show registry" and parse the output. You have CommandAction and ManagerResponse classes for that. In the case of IAX I'm doing: CommandAction commandAction; ManagerResponse commandResponse; commandAction = new CommandAction(); commandAction.setCommand("database show IAX"); try { commandResponse = managerConnection.sendAction(commandAction, 10000); } catch (TimeoutException te) { log.warn("DBshow action timeout"); return ""; } catch (IOException ioe) { log.warn("DBshow action exception"); return ""; } if (!commandResponse.getResponse().equals("Follows")) { log.warn("DBShow action error:" + commandResponse.getResponse()); return ""; } // 0 1 // 0123456789012345 // /IAX/Registry/31 : 172.30.0.2:4569:60 // --END COMMAND-- for (String line : ((CommandResponse)commandResponse).getResult()) { log.info(line); if (line.substring(0,14).equals("/IAX/Registry/")) { int c1 = line.indexOf(' ',14); int c2 = line.indexOf(':',c1); int c3 = line.indexOf(':',c2+1); String id = line.substring(14,c1); // 31 String ip = line.substring(c2+1,c3).trim(); // 172.30.0.2 iaxpeersId.put(id, ip); iaxpeersIp.put(ip, id); } } HTH. Haar Tobias @ 09/08/2007 04:25 -0300 dixit: > Hi > > I am using your software asterisk-java, but i met a simple problem. > > I would like to get a list of all registered extensions (display name, > id, etc.). > > Many thanks > > Tobias Haar from Germany > software developer > > alpha 2000 GmbH > Robert-Schumann-Str. 13 > 04107 Leipzig > Tel: +49 341 91918-36 > Fax: +49 341 91918-17 > Mail: ha...@al... > Web: www.alpha2000.de > > Hauptsitz: alpha 2000 GmbH, Robert-Schumann-Strasse 13, 04107 Leipzig > Geschaftsfuhrer: Matthias Bruehl, Dietmar Schulz > Registergericht: Amtsgericht Leipzig, HRB 3132 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > -- Carlos G Mendioroz <tr...@ac...> |