asterisk-java-cvs Mailing List for Asterisk-Java Library (Page 83)
Brought to you by:
srt
You can subscribe to this list here.
2005 |
Jan
(4) |
Feb
(75) |
Mar
(211) |
Apr
(70) |
May
(12) |
Jun
(7) |
Jul
(96) |
Aug
(90) |
Sep
(11) |
Oct
(42) |
Nov
(45) |
Dec
(4) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(20) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(32) |
Aug
|
Sep
(4) |
Oct
(2) |
Nov
(10) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(3) |
Aug
(73) |
Sep
(13) |
Oct
(4) |
Nov
(1) |
Dec
(7) |
2009 |
Jan
(1) |
Feb
(2) |
Mar
(48) |
Apr
(21) |
May
(14) |
Jun
(11) |
Jul
(9) |
Aug
(2) |
Sep
(11) |
Oct
(14) |
Nov
(6) |
Dec
(4) |
2010 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
|
May
(3) |
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
(9) |
Nov
|
Dec
(12) |
2011 |
Jan
(1) |
Feb
(5) |
Mar
(7) |
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(10) |
Sep
|
Oct
(5) |
Nov
|
Dec
|
2012 |
Jan
(3) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
(2) |
Dec
(2) |
2013 |
Jan
|
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(5) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(25) |
May
(10) |
Jun
(4) |
Jul
(7) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(3) |
Dec
(1) |
2016 |
Jan
|
Feb
(42) |
Mar
(6) |
Apr
(15) |
May
(3) |
Jun
(1) |
Jul
(11) |
Aug
|
Sep
|
Oct
(17) |
Nov
(2) |
Dec
|
2017 |
Jan
|
Feb
(4) |
Mar
(1) |
Apr
(3) |
May
(2) |
Jun
(3) |
Jul
(7) |
Aug
(11) |
Sep
(5) |
Oct
(7) |
Nov
(4) |
Dec
(4) |
2018 |
Jan
(11) |
Feb
(11) |
Mar
(3) |
Apr
|
May
(9) |
Jun
(6) |
Jul
(17) |
Aug
(9) |
Sep
(2) |
Oct
(4) |
Nov
(3) |
Dec
(3) |
2019 |
Jan
(13) |
Feb
(1) |
Mar
(1) |
Apr
|
May
(5) |
Jun
|
Jul
(1) |
Aug
(6) |
Sep
|
Oct
|
Nov
(3) |
Dec
|
2020 |
Jan
(2) |
Feb
(72) |
Mar
(8) |
Apr
(11) |
May
(12) |
Jun
(3) |
Jul
(12) |
Aug
(3) |
Sep
(5) |
Oct
(4) |
Nov
|
Dec
(9) |
2021 |
Jan
|
Feb
(31) |
Mar
(6) |
Apr
(3) |
May
|
Jun
(2) |
Jul
|
Aug
(2) |
Sep
|
Oct
(9) |
Nov
|
Dec
(32) |
2022 |
Jan
(5) |
Feb
(7) |
Mar
(2) |
Apr
(3) |
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
(2) |
Oct
(111) |
Nov
(105) |
Dec
(26) |
2023 |
Jan
(25) |
Feb
(6) |
Mar
(10) |
Apr
(54) |
May
(41) |
Jun
(24) |
Jul
(6) |
Aug
(11) |
Sep
(9) |
Oct
(8) |
Nov
(55) |
Dec
(34) |
2024 |
Jan
(6) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(89) |
Sep
(48) |
Oct
(31) |
Nov
(9) |
Dec
(19) |
2025 |
Jan
(12) |
Feb
(18) |
Mar
(9) |
Apr
(7) |
May
|
Jun
(7) |
Jul
(5) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Stefan R. <sr...@us...> - 2005-07-01 16:36:39
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8200/src/java/net/sf/asterisk/fastagi Modified Files: AbstractAGIScript.java Log Message: added waitForDigit method Index: AbstractAGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AbstractAGIScript.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -p -r1.10 -r1.11 --- AbstractAGIScript.java 6 Apr 2005 16:51:47 -0000 1.10 +++ AbstractAGIScript.java 1 Jul 2005 16:36:30 -0000 1.11 @@ -35,6 +35,7 @@ import net.sf.asterisk.fastagi.command.S import net.sf.asterisk.fastagi.command.SetPriorityCommand; import net.sf.asterisk.fastagi.command.SetVariableCommand; import net.sf.asterisk.fastagi.command.StreamFileCommand; +import net.sf.asterisk.fastagi.command.WaitForDigitCommand; import net.sf.asterisk.fastagi.reply.AGIReply; /** @@ -339,16 +340,16 @@ public abstract class AbstractAGIScript } /** - * Says the given character string, returning early if any of - * the given DTMF number are received on the channel. + * Says the given character string, returning early if any of the given DTMF + * number are received on the channel. * * @param text the text to say. * @param escapeDigits a String containing the DTMF digits that allow the * user to escape. * @return the DTMF digit pressed or 0x0 if none was pressed. */ - protected char sayAlpha(AGIChannel channel, String text, - String escapeDigits) throws AGIException + protected char sayAlpha(AGIChannel channel, String text, String escapeDigits) + throws AGIException { AGIReply reply; @@ -361,23 +362,22 @@ public abstract class AbstractAGIScript * * @param time the time to say in seconds since 00:00:00 on January 1, 1970. */ - protected void sayTime(AGIChannel channel, long time) - throws AGIException + protected void sayTime(AGIChannel channel, long time) throws AGIException { channel.sendCommand(new SayTimeCommand(time)); } /** - * Says the given time, returning early if any of - * the given DTMF number are received on the channel. + * Says the given time, returning early if any of the given DTMF number are + * received on the channel. * * @param time the time to say in seconds since 00:00:00 on January 1, 1970. * @param escapeDigits a String containing the DTMF digits that allow the * user to escape. * @return the DTMF digit pressed or 0x0 if none was pressed. */ - protected char sayTime(AGIChannel channel, long time, - String escapeDigits) throws AGIException + protected char sayTime(AGIChannel channel, long time, String escapeDigits) + throws AGIException { AGIReply reply; @@ -416,4 +416,20 @@ public abstract class AbstractAGIScript { channel.sendCommand(new SetVariableCommand(name, value)); } + + /** + * Waits up to 'timeout' milliseconds to receive a DTMF digit. + * + * @param timeout timeout the milliseconds to wait for the channel to + * receive a DTMF digit, -1 will wait forever. + * @return the DTMF digit pressed or 0x0 if none was pressed. + */ + protected char waitForDigit(AGIChannel channel, int timeout) + throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new WaitForDigitCommand(timeout)); + return reply.getResultCodeAsChar(); + } } |
From: Stefan R. <sr...@us...> - 2005-06-23 22:17:56
|
Update of /cvsroot/asterisk-java/asterisk-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2015 Modified Files: ChangeLog Log Message: updated ChangeLog to reflect isConnected method addition Index: ChangeLog =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/ChangeLog,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- ChangeLog 24 Apr 2005 15:47:11 -0000 1.2 +++ ChangeLog 23 Jun 2005 22:17:45 -0000 1.3 @@ -1,5 +1,9 @@ -asterisk-java 0.1 +Asterisk-Java 0.2 + * Fixed getting the uniqueId from a successful originate + in the DefaultAsteriskManager + * Added isConnected() method to ManagerConnection +Asterisk-Java 0.1 * Added accessors for raw attributes in ManagerResponse * Fixed bug in action id creation * Changed logging to use either log4j or java.util.logging |
From: Stefan R. <sr...@us...> - 2005-06-23 22:16:14
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1356/src/java/net/sf/asterisk/manager Modified Files: DefaultManagerConnection.java Log Message: fixed broken unit tests due to isConnected() method additon Index: DefaultManagerConnection.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultManagerConnection.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -p -r1.16 -r1.17 --- DefaultManagerConnection.java 23 Jun 2005 22:06:09 -0000 1.16 +++ DefaultManagerConnection.java 23 Jun 2005 22:16:03 -0000 1.17 @@ -264,7 +264,7 @@ public class DefaultManagerConnection im LoginAction loginAction; ManagerResponse loginResponse; - if (!isConnected()) + if (socket == null) { connect(); } @@ -389,7 +389,7 @@ public class DefaultManagerConnection im logoffAction = new LogoffAction(); - if (isConnected()) + if (socket != null) { sendAction(logoffAction); disconnect(); @@ -465,7 +465,7 @@ public class DefaultManagerConnection im "Unable to send action: action is null."); } - if (!isConnected()) + if (socket == null) { throw new IllegalStateException("Unable to send " + action.getAction() + " action: not connected."); |
From: Stefan R. <sr...@us...> - 2005-06-23 22:06:20
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29391/src/java/net/sf/asterisk/manager Modified Files: DefaultManagerConnection.java ManagerConnection.java Log Message: Added isConnected() to ManagerConnection Index: DefaultManagerConnection.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultManagerConnection.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -p -r1.15 -r1.16 --- DefaultManagerConnection.java 23 Apr 2005 22:56:38 -0000 1.15 +++ DefaultManagerConnection.java 23 Jun 2005 22:06:09 -0000 1.16 @@ -48,7 +48,8 @@ import net.sf.asterisk.util.LogFactory; * Default implemention of the ManagerConnection interface. * * @author srt - * @version $Id$ + * @version $Id: DefaultManagerConnection.java,v 1.15 2005/04/23 22:56:38 srt + * Exp $ */ public class DefaultManagerConnection implements ManagerConnection, Dispatcher { @@ -93,7 +94,8 @@ public class DefaultManagerConnection im this.eventHandlers = new HashSet(); } - public DefaultManagerConnection(String hostname, int port, String username, String password) + public DefaultManagerConnection(String hostname, int port, String username, + String password) { this(); @@ -103,7 +105,8 @@ public class DefaultManagerConnection im setPassword(password); } - protected ManagerReader createReader(Dispatcher dispatcher, AsteriskServer server) + protected ManagerReader createReader(Dispatcher dispatcher, + AsteriskServer server) { return new ManagerReaderImpl(dispatcher, server); } @@ -125,8 +128,8 @@ public class DefaultManagerConnection im } /** - * Sets the port to use to connect to the asterisk server. This is the port specified in - * asterisk's <code>manager.conf</code> file.<br> + * Sets the port to use to connect to the asterisk server. This is the port + * specified in asterisk's <code>manager.conf</code> file.<br> * Default is 5038. * * @param port the port to connect to @@ -137,8 +140,8 @@ public class DefaultManagerConnection im } /** - * Sets the username to use to connect to the asterisk server. This is the username specified in - * asterisk's <code>manager.conf</code> file. + * Sets the username to use to connect to the asterisk server. This is the + * username specified in asterisk's <code>manager.conf</code> file. * * @param username the username to use for login */ @@ -148,8 +151,8 @@ public class DefaultManagerConnection im } /** - * Sets the password to use to connect to the asterisk server. This is the password specified in - * asterisk's <code>manager.conf</code> file. + * Sets the password to use to connect to the asterisk server. This is the + * password specified in asterisk's <code>manager.conf</code> file. * * @param password the password to use for login */ @@ -159,8 +162,9 @@ public class DefaultManagerConnection im } /** - * Sets the time in milli seconds the synchronous method {@link #sendAction(ManagerAction)} will - * wait for a response before throwing a TimeoutException.<br> + * Sets the time in milli seconds the synchronous method + * {@link #sendAction(ManagerAction)} will wait for a response before + * throwing a TimeoutException.<br> * Default is 2000. * * @param defaultTimeout default timeout in milli seconds @@ -171,13 +175,14 @@ public class DefaultManagerConnection im } /** - * Sets the time in milli seconds the synchronous methods {@link #sendAction(ManagerAction)} and - * {@link #sendAction(ManagerAction, long)} will sleep between two checks for the arrival of a - * response. This value should be rather small.<br> + * Sets the time in milli seconds the synchronous methods + * {@link #sendAction(ManagerAction)} and + * {@link #sendAction(ManagerAction, long)} will sleep between two checks + * for the arrival of a response. This value should be rather small.<br> * Default is 50. * - * @param sleepTime time in milli seconds to sleep between two checks for the arrival of a - * responser + * @param sleepTime time in milli seconds to sleep between two checks for + * the arrival of a responser */ public void setSleepTime(long sleepTime) { @@ -185,11 +190,12 @@ public class DefaultManagerConnection im } /** - * Set to <code>true</code> to try reconnecting to ther asterisk serve even if the - * reconnection attempt threw an AuthenticationFailedException.<br> + * Set to <code>true</code> to try reconnecting to ther asterisk serve + * even if the reconnection attempt threw an AuthenticationFailedException.<br> * Default is <code>false</code>. */ - public void setKeepAliveAfterAuthenticationFailure(boolean keepAliveAfterAuthenticationFailure) + public void setKeepAliveAfterAuthenticationFailure( + boolean keepAliveAfterAuthenticationFailure) { this.keepAliveAfterAuthenticationFailure = keepAliveAfterAuthenticationFailure; } @@ -207,16 +213,19 @@ public class DefaultManagerConnection im } /** - * Logs in to the asterisk manager using asterisk's MD5 based challenge/response protocol. The - * login is delayed until the protocol identifier has been received by the reader. - * - * @throws AuthenticationFailedException if the username and/or password are incorrect - * @throws TimeoutException if no response is received within the specified timeout period + * Logs in to the asterisk manager using asterisk's MD5 based + * challenge/response protocol. The login is delayed until the protocol + * identifier has been received by the reader. * + * @throws AuthenticationFailedException if the username and/or password are + * incorrect + * @throws TimeoutException if no response is received within the specified + * timeout period * @see ChallengeAction * @see LoginAction */ - public void login() throws IOException, AuthenticationFailedException, TimeoutException + public void login() throws IOException, AuthenticationFailedException, + TimeoutException { login(defaultTimeout); } @@ -224,22 +233,29 @@ public class DefaultManagerConnection im /** * Does the real login, following the steps outlined below.<br> * <ol> - * <li>Connects to the asterisk server by calling {@link #connect()} if not already connected - * <li>Waits until the protocol identifier is received. This is checked every - * {@link #sleepTime} ms but not longer than timeout ms in total. - * <li>Sends a {@link ChallengeAction} requesting a challenge for authType MD5. - * <li>When the {@link ChallengeResponse} is received a {@link LoginAction} is sent using the - * calculated key (MD5 hash of the password appended to the received challenge). + * <li>Connects to the asterisk server by calling {@link #connect()} if not + * already connected + * <li>Waits until the protocol identifier is received. This is checked + * every {@link #sleepTime} ms but not longer than timeout ms in total. + * <li>Sends a {@link ChallengeAction} requesting a challenge for authType + * MD5. + * <li>When the {@link ChallengeResponse} is received a {@link LoginAction} + * is sent using the calculated key (MD5 hash of the password appended to + * the received challenge). * </ol> * - * @param timeout the maximum time to wait for the protocol identifier (in ms) - * @throws AuthenticationFailedException if username or password are incorrect and the login - * action returns an error or if the MD5 hash cannot be computed. The connection is closed in - * this case. - * @throws TimeoutException if a timeout occurs either while waiting for the protocol identifier - * or when sending the challenge or login action. The connection is closed in this case. + * @param timeout the maximum time to wait for the protocol identifier (in + * ms) + * @throws AuthenticationFailedException if username or password are + * incorrect and the login action returns an error or if the MD5 + * hash cannot be computed. The connection is closed in this + * case. + * @throws TimeoutException if a timeout occurs either while waiting for the + * protocol identifier or when sending the challenge or login + * action. The connection is closed in this case. */ - private void login(long timeout) throws IOException, AuthenticationFailedException, TimeoutException + private void login(long timeout) throws IOException, + AuthenticationFailedException, TimeoutException { long timeSpent; ChallengeAction challengeAction; @@ -264,7 +280,8 @@ public class DefaultManagerConnection im if (timeSpent > timeout) { disconnect(); - throw new TimeoutException("Timeout waiting for protocol identifier"); + throw new TimeoutException( + "Timeout waiting for protocol identifier"); } } catch (InterruptedException e) @@ -298,7 +315,8 @@ public class DefaultManagerConnection im catch (NoSuchAlgorithmException ex) { disconnect(); - throw new AuthenticationFailedException("Unable to create login key using MD5 Message Digest", ex); + throw new AuthenticationFailedException( + "Unable to create login key using MD5 Message Digest", ex); } loginResponse = sendAction(loginAction); @@ -308,7 +326,8 @@ public class DefaultManagerConnection im throw new AuthenticationFailedException(loginResponse.getMessage()); } - // successfully logged in so assure that we keep trying to reconnect when + // successfully logged in so assure that we keep trying to reconnect + // when // disconnected this.keepAlive = true; @@ -317,7 +336,8 @@ public class DefaultManagerConnection im protected synchronized void connect() throws IOException { - logger.info("Connecting to " + asteriskServer.getHostname() + " port " + asteriskServer.getPort()); + logger.info("Connecting to " + asteriskServer.getHostname() + " port " + + asteriskServer.getPort()); if (this.reader == null) { @@ -340,20 +360,21 @@ public class DefaultManagerConnection im protected SocketConnectionFacade createSocket() throws IOException { - return new SocketConnectionFacadeImpl(asteriskServer.getHostname(), asteriskServer.getPort()); + return new SocketConnectionFacadeImpl(asteriskServer.getHostname(), + asteriskServer.getPort()); } /** - * Returns <code>true</code> if there is a socket connection to the asterisk server, - * <code>false</code> otherwise. + * Returns <code>true</code> if there is a socket connection to the + * asterisk server, <code>false</code> otherwise. * - * @return <code>true</code> if there is a socket connection to the asterisk server, - * <code>false</code> otherwise. + * @return <code>true</code> if there is a socket connection to the + * asterisk server, <code>false</code> otherwise. */ - private synchronized boolean isConnected() + public synchronized boolean isConnected() { - // return socket != null && socket.isConnected(); // JDK 1.4 - return socket != null; + return socket != null && socket.isConnected(); // JDK 1.4 + //return socket != null; } /** @@ -392,12 +413,14 @@ public class DefaultManagerConnection im } } - public ManagerResponse sendAction(ManagerAction action) throws IOException, TimeoutException + public ManagerResponse sendAction(ManagerAction action) throws IOException, + TimeoutException { return sendAction(action, defaultTimeout); } - public ManagerResponse sendAction(ManagerAction action, long timeout) throws IOException, TimeoutException + public ManagerResponse sendAction(ManagerAction action, long timeout) + throws IOException, TimeoutException { long timeSpent; ResponseHandlerResult result; @@ -418,7 +441,9 @@ public class DefaultManagerConnection im if (timeSpent > timeout) { - throw new TimeoutException("Timeout waiting for response to " + action.getAction()); + throw new TimeoutException( + "Timeout waiting for response to " + + action.getAction()); } } catch (InterruptedException ex) @@ -429,22 +454,26 @@ public class DefaultManagerConnection im return result.getResponse(); } - public void sendAction(ManagerAction action, ManagerResponseHandler callbackHandler) throws IOException + public void sendAction(ManagerAction action, + ManagerResponseHandler callbackHandler) throws IOException { String internalActionId; if (action == null) { - throw new IllegalArgumentException("Unable to send action: action is null."); + throw new IllegalArgumentException( + "Unable to send action: action is null."); } if (!isConnected()) { - throw new IllegalStateException("Unable to send " + action.getAction() + " action: not connected."); + throw new IllegalStateException("Unable to send " + + action.getAction() + " action: not connected."); } internalActionId = createInternalActionId(); - action.setActionId(Util.addInternalActionId(action.getActionId(), internalActionId)); + action.setActionId(Util.addInternalActionId(action.getActionId(), + internalActionId)); if (callbackHandler != null) { @@ -458,8 +487,8 @@ public class DefaultManagerConnection im } /** - * Creates a new unique internal action id based on the hash code of this connection and a - * sequence. + * Creates a new unique internal action id based on the hash code of this + * connection and a sequence. */ private String createInternalActionId() { @@ -497,14 +526,19 @@ public class DefaultManagerConnection im return this.protocolIdentifier; } + public AsteriskServer getAsteriskServer() + { + return asteriskServer; + } + /* Callbacks for ManagerReaderImpl */ /** - * This method is called by the reader whenever a {@link ManagerResponse} is received. The - * response is dispatched to the associated {@link ManagerResponseHandler}. + * This method is called by the reader whenever a {@link ManagerResponse} is + * received. The response is dispatched to the associated + * {@link ManagerResponseHandler}. * * @param response the resonse received by the reader - * * @see ManagerReader */ public void dispatchResponse(ManagerResponse response) @@ -529,27 +563,32 @@ public class DefaultManagerConnection im response.setActionId(Util.stripInternalActionId(actionId)); } - logger.debug("Dispatching response with internalActionId '" + internalActionId + "':\n" + response); + logger.debug("Dispatching response with internalActionId '" + + internalActionId + "':\n" + response); if (internalActionId != null) { synchronized (this.responseHandlers) { - responseHandler = (ManagerResponseHandler) this.responseHandlers.get(internalActionId); + responseHandler = (ManagerResponseHandler) this.responseHandlers + .get(internalActionId); if (responseHandler != null) { this.responseHandlers.remove(internalActionId); } else { - logger.warn("No response handler registered for internalActionId '" + internalActionId + "'"); + logger + .warn("No response handler registered for internalActionId '" + + internalActionId + "'"); } } } else { - logger.error("Unable to retrieve internalActionId from response: asterisk sent actionId '" + actionId - + "':\n" + response); + logger + .error("Unable to retrieve internalActionId from response: asterisk sent actionId '" + + actionId + "':\n" + response); } if (responseHandler != null) @@ -570,11 +609,10 @@ public class DefaultManagerConnection im } /** - * This method is called by the reader whenever a ManagerEvent is received. The event is - * dispatched to all registered ManagerEventHandlers. + * This method is called by the reader whenever a ManagerEvent is received. + * The event is dispatched to all registered ManagerEventHandlers. * * @param event the event received by the reader - * * @see #addEventHandler(ManagerEventHandler) * @see #removeEventHandler(ManagerEventHandler) * @see ManagerReader @@ -610,7 +648,8 @@ public class DefaultManagerConnection im if (event instanceof ConnectEvent) { - setProtocolIdentifier(((ConnectEvent) event).getProtocolIdentifier()); + setProtocolIdentifier(((ConnectEvent) event) + .getProtocolIdentifier()); } if (event instanceof DisconnectEvent) { @@ -619,10 +658,12 @@ public class DefaultManagerConnection im } /** - * This method is called when a {@link ConnectEvent} is received from the reader. Having - * received a correct protocol identifier is the precodition for logging in. + * This method is called when a {@link ConnectEvent} is received from the + * reader. Having received a correct protocol identifier is the precodition + * for logging in. * - * @param protocolIdentifier the protocol version used by the asterisk server. + * @param protocolIdentifier the protocol version used by the asterisk + * server. */ private void setProtocolIdentifier(final String protocolIdentifier) { @@ -630,9 +671,11 @@ public class DefaultManagerConnection im if (!"Asterisk Call Manager/1.0".equals(protocolIdentifier)) { - logger.warn("Unsupported protocol version '" + protocolIdentifier - + "'. This library has only been tested with version 1.0 of the asterisk " - + "call manager protocol. Use at your own risk!"); + logger + .warn("Unsupported protocol version '" + + protocolIdentifier + + "'. This library has only been tested with version 1.0 of the asterisk " + + "call manager protocol. Use at your own risk!"); } this.protocolIdentifier = protocolIdentifier; @@ -640,11 +683,14 @@ public class DefaultManagerConnection im /** * Reconnects to the asterisk server when the connection is lost.<br> - * While keepAlive is <code>true</code> we will try to reconnect. Reconnection attempts will - * be stopped when the {@link #logoff()} method is called or when the login after a successful - * reconnect results in an {@link AuthenticationFailedException} suggesting that the manager - * credentials have changed and keepAliveAfterAuthenticationFailure is not set.<br> - * This method is called when a {@link DisconnectEvent} is received from the reader. + * While keepAlive is <code>true</code> we will try to reconnect. + * Reconnection attempts will be stopped when the {@link #logoff()} method + * is called or when the login after a successful reconnect results in an + * {@link AuthenticationFailedException} suggesting that the manager + * credentials have changed and keepAliveAfterAuthenticationFailure is not + * set.<br> + * This method is called when a {@link DisconnectEvent} is received from the + * reader. */ private void reconnect() { @@ -712,8 +758,10 @@ public class DefaultManagerConnection im } catch (IOException e) { - // server seems to be still down, just continue to attempt reconnection - logger.warn("Exception while trying to reconnect: " + e.getMessage()); + // server seems to be still down, just continue to attempt + // reconnection + logger.warn("Exception while trying to reconnect: " + + e.getMessage()); } numTries++; } @@ -748,10 +796,13 @@ public class DefaultManagerConnection im } /** - * A simple response handler that stores the received response in a ResponseHandlerResult for - * further processing. + * A simple response handler that stores the received response in a + * ResponseHandlerResult for further processing. */ - private class DefaultResponseHandler implements ManagerResponseHandler, Serializable + private class DefaultResponseHandler + implements + ManagerResponseHandler, + Serializable { /** * Serializable version identifier @@ -769,12 +820,4 @@ public class DefaultManagerConnection im this.result.setResponse(response); } } - - /** - * @return Returns the asteriskServer. - */ - public AsteriskServer getAsteriskServer() - { - return asteriskServer; - } } Index: ManagerConnection.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/ManagerConnection.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -p -r1.6 -r1.7 --- ManagerConnection.java 15 Apr 2005 04:46:59 -0000 1.6 +++ ManagerConnection.java 23 Jun 2005 22:06:10 -0000 1.7 @@ -22,11 +22,11 @@ import net.sf.asterisk.manager.action.Ma import net.sf.asterisk.manager.response.ManagerResponse; /** - * The main interface to talk to an Asterisk server via the Asterisk Manager API. A concrete - * implementation of this interface can be obtained from a ManagerConnectionFactory. + * The main interface to talk to an Asterisk server via the Asterisk Manager + * API. A concrete implementation of this interface can be obtained from a + * ManagerConnectionFactory. * * @see net.sf.asterisk.manager.ManagerConnectionFactory - * * @author srt * @version $Id$ */ @@ -34,107 +34,111 @@ public interface ManagerConnection { /** * Registers a new user event type.<br> - * Asterisk allows you to send custom events via the UserEvent application. If you choose to - * send such events you can extend the abstract class UserEvent provide a name for your new - * event and optionally add your own attributes. After registering a user event type - * asterisk-java will handle such events the same way it handles the internal events and inform - * your registered event handlers.<br> + * Asterisk allows you to send custom events via the UserEvent application. + * If you choose to send such events you can extend the abstract class + * UserEvent provide a name for your new event and optionally add your own + * attributes. After registering a user event type asterisk-java will handle + * such events the same way it handles the internal events and inform your + * registered event handlers.<br> * Note: If you write your own asterisk applications that use asterisk's - * <code>manager_event()</code> function directly and don't use the channel and uniqueid - * attributes provided by UserEvent you can also register events that directly subclass - * ManagerEvent. + * <code>manager_event()</code> function directly and don't use the + * channel and uniqueid attributes provided by UserEvent you can also + * register events that directly subclass ManagerEvent. * * @see net.sf.asterisk.manager.event.UserEvent * @see ManagerEvent - * * @param userEventClass the class of the user event to register. */ void registerUserEventClass(Class userEventClass); /** - * Logs in to the asterisk server with the username and password specified when this connection - * was created. + * Logs in to the asterisk server with the username and password specified + * when this connection was created. * * @throws IOException if the network connection is disrupted. - * @throws AuthenticationFailedException if the username and/or password are incorrect or the - * ChallengeResponse could not be built. - * @throws TimeoutException if no response is received within the default timeout period. If the - * implementation uses challenge/response this can either be a timeout of the ChallengeAction or - * the LoginAction; otherwise it is always a timeout of the LoginAction. - * + * @throws AuthenticationFailedException if the username and/or password are + * incorrect or the ChallengeResponse could not be built. + * @throws TimeoutException if no response is received within the default + * timeout period. If the implementation uses challenge/response + * this can either be a timeout of the ChallengeAction or the + * LoginAction; otherwise it is always a timeout of the + * LoginAction. * @see net.sf.asterisk.manager.action.LoginAction * @see net.sf.asterisk.manager.action.ChallengeAction */ - void login() throws IOException, AuthenticationFailedException, TimeoutException; + void login() throws IOException, AuthenticationFailedException, + TimeoutException; /** * Sends a LogoffAction to the asterisk server and disconnects. * * @throws IOException if the network connection is disrupted. - * @throws TimeoutException if no response to the logoff action is received within the default - * timeout period. - * + * @throws TimeoutException if no response to the logoff action is received + * within the default timeout period. * @see net.sf.asterisk.manager.action.LogoffAction */ void logoff() throws IOException, TimeoutException; /** - * Returns the protocol identifier, i.e. a string like "Asterisk Call Manager/1.0". + * Returns the protocol identifier, i.e. a string like "Asterisk Call + * Manager/1.0". * - * @return the protocol identifier of the asterisk manager interface in use if it has already - * been received; <code>null</code> otherwise + * @return the protocol identifier of the asterisk manager interface in use + * if it has already been received; <code>null</code> otherwise */ String getProtocolIdentifier(); /** - * Sends a ManagerAction to the asterisk manager interface and waits for the corresponding - * ManagerResponse. + * Sends a ManagerAction to the asterisk manager interface and waits for the + * corresponding ManagerResponse. * * @param action the action to send to the asterisk server - * * @return the corresponding response received from the asterisk server - * * @throws IOException if the network connection is disrupted. - * @throws TimeoutException if no reponse is received within the default timeout period. - * + * @throws TimeoutException if no reponse is received within the default + * timeout period. * @see #sendAction(ManagerAction, long) * @see #sendAction(ManagerAction, ManagerResponseHandler) */ - ManagerResponse sendAction(ManagerAction action) throws IOException, TimeoutException; + ManagerResponse sendAction(ManagerAction action) throws IOException, + TimeoutException; /** - * Sends a ManagerAction to the asterisk manager interface and waits for the corresponding - * {@link ManagerResponse}. + * Sends a ManagerAction to the asterisk manager interface and waits for the + * corresponding {@link ManagerResponse}. * * @param action the action to send to the asterisk server - * @param timeout milliseconds to wait for the reponse before throwing a TimeoutException - * + * @param timeout milliseconds to wait for the reponse before throwing a + * TimeoutException * @return the corresponding response received from the asterisk server - * * @throws IOException if the network connection is disrupted. - * @throws TimeoutException if no reponse is received within the given timeout period. - * + * @throws TimeoutException if no reponse is received within the given + * timeout period. * @see #sendAction(ManagerAction, ManagerResponseHandler) */ - ManagerResponse sendAction(ManagerAction action, long timeout) throws IOException, TimeoutException; + ManagerResponse sendAction(ManagerAction action, long timeout) + throws IOException, TimeoutException; /** - * Sends a ManagerAction to the asterisk manager interface and registers a callback handler to - * be called when the corresponding ManagerResponse is received. + * Sends a ManagerAction to the asterisk manager interface and registers a + * callback handler to be called when the corresponding ManagerResponse is + * received. * * @param action the action to send to the asterisk server - * @param callbackHandler the callback handler to call when the response is received - * + * @param callbackHandler the callback handler to call when the response is + * received * @throws IOException if the network connection is disrupted. */ - void sendAction(ManagerAction action, ManagerResponseHandler callbackHandler) throws IOException; + void sendAction(ManagerAction action, ManagerResponseHandler callbackHandler) + throws IOException; /** * Registers an event handler to be called whenever an - * {@link net.sf.asterisk.manager.event.ManagerEvent} is receiced from the asterisk server. - * - * @param eventHandler the handler to call whenever a manager event is received + * {@link net.sf.asterisk.manager.event.ManagerEvent} is receiced from the + * asterisk server. * + * @param eventHandler the handler to call whenever a manager event is + * received * @see #removeEventHandler(ManagerEventHandler) */ void addEventHandler(ManagerEventHandler eventHandler); @@ -144,7 +148,6 @@ public interface ManagerConnection * Does nothing if the given event handler hasn't be been regiered before. * * @param eventHandler the event handle to unregister - * * @see #addEventHandler(ManagerEventHandler) */ void removeEventHandler(ManagerEventHandler eventHandler); @@ -155,4 +158,13 @@ public interface ManagerConnection * @return the Asterisk server of this connection. */ AsteriskServer getAsteriskServer(); + + /** + * Checks if the connection to the Asterisk server is established. + * + * @return <code>true</code> if the connection is established, + * <code>false</code> otherwise. + * @since 0.2 + */ + boolean isConnected(); } |
From: Stefan R. <sr...@us...> - 2005-06-23 22:06:19
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/io In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29391/src/java/net/sf/asterisk/io Modified Files: SocketConnectionFacade.java SocketConnectionFacadeImpl.java Log Message: Added isConnected() to ManagerConnection Index: SocketConnectionFacade.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/io/SocketConnectionFacade.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- SocketConnectionFacade.java 8 Mar 2005 16:48:35 -0000 1.1 +++ SocketConnectionFacade.java 23 Jun 2005 22:06:10 -0000 1.2 @@ -65,4 +65,12 @@ public interface SocketConnectionFacade * @throws IOException if the socket connection cannot be closed. */ void close() throws IOException; + + /** + * Returns the connection state of the socket. + * + * @return <code>true</code> if the socket successfuly connected to a + * server + */ + boolean isConnected(); } Index: SocketConnectionFacadeImpl.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/io/SocketConnectionFacadeImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- SocketConnectionFacadeImpl.java 8 Mar 2005 16:48:35 -0000 1.1 +++ SocketConnectionFacadeImpl.java 23 Jun 2005 22:06:10 -0000 1.2 @@ -62,4 +62,9 @@ public class SocketConnectionFacadeImpl { this.socket.close(); } + + public boolean isConnected() + { + return socket.isConnected(); + } } |
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30218/src/java/net/sf/asterisk/manager Modified Files: DefaultAsteriskManager.java AsteriskManager.java MultiAsterisksManager.java Added Files: Call.java Originate.java Log Message: Included Ben Hencke's patch for the "UniqueId and originate command" problem. --- NEW FILE: Call.java --- /* * Copyright 2004-2005 Stefan Reuter * * Copyright 2005 Ben Hencke * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.sf.asterisk.manager; import java.util.*; /** * @author Ben Hencke */ public class Call { private String uniqueId; private Integer reason; private Channel channel; private Date startTime; private Date endTime; public Call() { startTime = new Date(); } public String getUniqueId() { return uniqueId; } public void setUniqueId(String uniqueId) { this.uniqueId = uniqueId; } public Channel getChannel() { return channel; } public void setChannel(Channel channel) { this.channel = channel; } public Integer getReason() { return reason; } public void setReason(Integer reason) { this.reason = reason; } public Date getStartTime() { return startTime; } public void setStartTime(Date startTime) { this.startTime = startTime; } public Date getEndTime() { return endTime; } public void setEndTime(Date endTime) { this.endTime = endTime; } /** * @return The duration of the call in milliseconds. If the call is has not * ended, the duration so far is calculated. */ public long calcDuration() { Date compTime; if (endTime != null) { compTime = endTime; } else { compTime = new Date(); } return compTime.getTime() - startTime.getTime(); } public String toString() { StringBuffer sb; sb = new StringBuffer(getClass().getName() + ": "); sb.append("uniqueId=" + getUniqueId() + "; "); sb.append("reason=" + getReason() + "; "); sb.append("startTime=" + getStartTime() + "; "); sb.append("endTime=" + getEndTime() + "; "); sb.append("systemHashcode=" + System.identityHashCode(this)); return sb.toString(); } } --- NEW FILE: Originate.java --- /* * Copyright 2004-2005 Stefan Reuter * * Copyright 2005 Ben Hencke * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.sf.asterisk.manager; import java.util.*; /** * @author Ben Hencke */ public class Originate { private String channel; private String exten; private String context; private Integer priority; private Integer timeout; private String callerId; private Map variables = new HashMap(); private String account; private String application; private String data; /** * Returns the account code to use for the originated call. */ public String getAccount() { return account; } /** * Sets the account code to use for the originated call.<br> * The account code is included in the call detail record generated for this * call and will be used for billing. */ public void setAccount(String account) { this.account = account; } /** * Returns the caller id to set on the outgoing channel. */ public String getCallerId() { return callerId; } /** * Sets the caller id to set on the outgoing channel. */ public void setCallerId(String callerId) { this.callerId = callerId; } /** * Returns the name of the channel to connect to the outgoing call. */ public String getChannel() { return channel; } /** * Sets the name of the channel to connect to the outgoing call.<br> * This property is required. */ public void setChannel(String channel) { this.channel = channel; } /** * Returns the name of the context of the extension to connect to. */ public String getContext() { return context; } /** * Sets the name of the context of the extension to connect to.<br> * If you set the context you also have to set the exten and priority * properties. */ public void setContext(String context) { this.context = context; } /** * Returns the extension to connect to. */ public String getExten() { return exten; } /** * Sets the extension to connect to.<br> * If you set the extension you also have to set the context and priority * properties. */ public void setExten(String exten) { this.exten = exten; } /** * Returns the priority of the extension to connect to. */ public Integer getPriority() { return priority; } /** * Sets the priority of the extension to connect to. If you set the priority * you also have to set the context and exten properties. */ public void setPriority(Integer priority) { this.priority = priority; } /** * Returns the name of the application to connect to. */ public String getApplication() { return application; } /** * Sets the name of the application to connect to. */ public void setApplication(String application) { this.application = application; } /** * Returns the parameters to pass to the application. */ public String getData() { return data; } /** * Sets the parameters to pass to the application. */ public void setData(String data) { this.data = data; } /** * Returns the timeout for the origination. */ public Integer getTimeout() { return timeout; } /** * Sets the timeout (in milliseconds) for the origination.<br> * The channel must be answered within this time, otherwise the origination * is considered to have failed and an OriginateFailureEvent is generated.<br> * If not set, asterisk assumes a default value of 30000 meaning 30 seconds. */ public void setTimeout(Integer timeout) { this.timeout = timeout; } /** * Returns the variables to set on the originated call. */ public Map getVariables() { return variables; } /** * Sets the variables to set on the originated call. */ public void setVariables(Map variables) { this.variables = variables; } /** * Sets a variable on the originated call. Replaces any existing variable * with the same name. */ public void setVariable(String name, String value) { variables.put(name, value); } /** * Returns the variables to set on the originated call in native asterisk * format.<br> * Example: "VAR1=abc|VAR2=def". */ public String getVariableString() { StringBuffer varstring = new StringBuffer(); Iterator i = variables.entrySet().iterator(); while (i.hasNext()) { Map.Entry var = (Map.Entry) i.next(); varstring.append(var.getKey()); varstring.append("|"); varstring.append(var.getValue()); } return varstring.toString(); } } Index: DefaultAsteriskManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultAsteriskManager.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- DefaultAsteriskManager.java 31 Mar 2005 22:29:50 -0000 1.4 +++ DefaultAsteriskManager.java 22 Jun 2005 18:27:12 -0000 1.5 @@ -36,6 +36,8 @@ import net.sf.asterisk.manager.event.Man import net.sf.asterisk.manager.event.NewChannelEvent; import net.sf.asterisk.manager.event.NewExtenEvent; import net.sf.asterisk.manager.event.NewStateEvent; +import net.sf.asterisk.manager.event.OriginateFailureEvent; +import net.sf.asterisk.manager.event.OriginateSuccessEvent; import net.sf.asterisk.manager.event.QueueEntryEvent; import net.sf.asterisk.manager.event.QueueMemberEvent; import net.sf.asterisk.manager.event.QueueParamsEvent; @@ -52,7 +54,10 @@ import net.sf.asterisk.util.LogFactory; * @author srt * @version $Id$ */ -public class DefaultAsteriskManager implements AsteriskManager, ManagerEventHandler +public class DefaultAsteriskManager + implements + AsteriskManager, + ManagerEventHandler { private final Log log = LogFactory.getLog(this.getClass()); private ManagerConnection connection; @@ -61,6 +66,17 @@ public class DefaultAsteriskManager impl * A map of all active channel by their unique id. */ private Map channels; + + /** + * A map of all of the originating calls by their actionid. + */ + private Map calls; + + /** + * Sequence to track calls. + */ + private int callSequence; + private Map queues; private List queuedEvents; private boolean channelsInitialized; @@ -70,6 +86,7 @@ public class DefaultAsteriskManager impl public DefaultAsteriskManager() { + this.calls = Collections.synchronizedMap(new HashMap()); this.channels = Collections.synchronizedMap(new HashMap()); this.queues = Collections.synchronizedMap(new HashMap()); this.queuedEvents = Collections.synchronizedList(new ArrayList()); @@ -85,23 +102,65 @@ public class DefaultAsteriskManager impl this.connection = connection; } - public void initialize() throws TimeoutException, IOException, AuthenticationFailedException + public void initialize() throws TimeoutException, IOException, + AuthenticationFailedException { connection.addEventHandler(this); connection.login(); - + loggedIn = true; connection.sendAction(new StatusAction()); connection.sendAction(new QueueStatusAction()); } - public String originateCall(OriginateAction originateAction) throws TimeoutException, IOException + public Call originateCall(Originate originate) throws TimeoutException, + IOException, Exception { - ManagerResponse response; + Call call; + OriginateAction originateAction; + String actionid; - response = connection.sendAction(originateAction); + call = new Call(); + originateAction = new OriginateAction(); + actionid = System.identityHashCode(this) + "#" + (++callSequence); - return response == null ? null : response.getUniqueId(); + // set the action properties + originateAction.setAccount(originate.getAccount()); + originateAction.setApplication(originate.getApplication()); + originateAction.setCallerId(originate.getCallerId()); + originateAction.setChannel(originate.getChannel()); + originateAction.setContext(originate.getContext()); + originateAction.setData(originate.getData()); + originateAction.setExten(originate.getExten()); + originateAction.setPriority(originate.getPriority()); + originateAction.setTimeout(originate.getTimeout()); + originateAction.setVariable(originate.getVariableString()); + + // must set async to true to receive OriginateEvents. + originateAction.setAsync(Boolean.TRUE); + originateAction.setActionId(actionid); + + ManagerResponse response = connection.sendAction(originateAction); + // TODO check the response, don't bother waiting for an originatesuccess + // or originatefailure if the response is bad + + if ("Success".equalsIgnoreCase(response.getResponse())) + { + // register and listen for the OriginateSuccess or OriginateFailure + // event + synchronized (call) + { + calls.put(actionid, call); + call.wait(); + } + } + else + { + call.setStartTime(new Date()); + call.setEndTime(call.getStartTime()); + } + + return call; } /** @@ -119,8 +178,8 @@ public class DefaultAsteriskManager impl /** * Handles all events received from the asterisk server.<br> - * Events are queued until channels and queues are initialized and then delegated to the - * dispatchEvent method. + * Events are queued until channels and queues are initialized and then + * delegated to the dispatchEvent method. */ public void handleEvent(ManagerEvent event) { @@ -213,6 +272,14 @@ public class DefaultAsteriskManager impl { handleHangupEvent((HangupEvent) event); } + else if (event instanceof OriginateSuccessEvent) + { + handleOriginateSuccessEvent((OriginateSuccessEvent) event); + } + else if (event instanceof OriginateFailureEvent) + { + handleOriginateFailureEvent((OriginateFailureEvent) event); + } } protected void addChannel(Channel channel) @@ -246,8 +313,8 @@ public class DefaultAsteriskManager impl channel = new Channel(event.getChannel(), event.getUniqueId()); if (event.getSeconds() != null) { - channel - .setDateOfCreation(new Date(System.currentTimeMillis() - (event.getSeconds().intValue() * 1000))); + channel.setDateOfCreation(new Date(System.currentTimeMillis() + - (event.getSeconds().intValue() * 1000))); } isNew = true; } @@ -288,7 +355,8 @@ public class DefaultAsteriskManager impl } /** - * Resets the internal state when the connection to the asterisk server is lost. + * Resets the internal state when the connection to the asterisk server is + * lost. */ protected void handleDisconnectEvent(DisconnectEvent disconnectEvent) { @@ -302,8 +370,8 @@ public class DefaultAsteriskManager impl } /** - * Requests the current state from the asterisk server after the connection to the asterisk - * server is restored. + * Requests the current state from the asterisk server after the connection + * to the asterisk server is restored. */ protected void handleConnectEvent(ConnectEvent connectEvent) { @@ -319,7 +387,7 @@ public class DefaultAsteriskManager impl } catch (Exception e) { - log.error("Unable to request channel status from asterisk server after reconnect.", e); + log.error("Unable to request channel status after reconnect.", e); } try @@ -328,7 +396,7 @@ public class DefaultAsteriskManager impl } catch (Exception e) { - log.error("Unable to request queue status from asterisk server after reconnect.", e); + log.error("Unable to request queue status after reconnect.", e); } } @@ -369,12 +437,14 @@ public class DefaultAsteriskManager impl if (queue == null) { - log.error("ignored QueueEntryEvent for unknown queue " + event.getQueue()); + log.error("ignored QueueEntryEvent for unknown queue " + + event.getQueue()); return; } if (channel == null) { - log.error("ignored QueueEntryEvent for unknown channel " + event.getChannel()); + log.error("ignored QueueEntryEvent for unknown channel " + + event.getChannel()); return; } @@ -422,7 +492,8 @@ public class DefaultAsteriskManager impl Channel channel = (Channel) channels.get(event.getUniqueId()); if (channel == null) { - log.error("Ignored NewExtenEvent for unknown channel " + event.getChannel()); + log.error("Ignored NewExtenEvent for unknown channel " + + event.getChannel()); return; } @@ -441,7 +512,8 @@ public class DefaultAsteriskManager impl Channel channel = (Channel) channels.get(event.getUniqueId()); if (channel == null) { - log.error("Ignored NewStateEvent for unknown channel " + event.getChannel()); + log.error("Ignored NewStateEvent for unknown channel " + + event.getChannel()); return; } @@ -453,7 +525,8 @@ public class DefaultAsteriskManager impl Channel channel = (Channel) channels.get(event.getUniqueId()); if (channel == null) { - log.error("Ignored HangupEvent for unknown channel " + event.getChannel()); + log.error("Ignored HangupEvent for unknown channel " + + event.getChannel()); return; } @@ -473,16 +546,19 @@ public class DefaultAsteriskManager impl if (channel1 == null) { - log.error("Ignored LinkEvent for unknown channel " + event.getChannel1()); + log.error("Ignored LinkEvent for unknown channel " + + event.getChannel1()); return; } if (channel2 == null) { - log.error("Ignored LinkEvent for unknown channel " + event.getChannel2()); + log.error("Ignored LinkEvent for unknown channel " + + event.getChannel2()); return; } - log.info("Linking channels " + channel1.getName() + " and " + channel2.getName()); + log.info("Linking channels " + channel1.getName() + " and " + + channel2.getName()); synchronized (this) { channel1.setLinkedChannel(channel2); @@ -497,16 +573,19 @@ public class DefaultAsteriskManager impl if (channel1 == null) { - log.error("Ignored UnlinkEvent for unknown channel " + event.getChannel1()); + log.error("Ignored UnlinkEvent for unknown channel " + + event.getChannel1()); return; } if (channel2 == null) { - log.error("Ignored UnlinkEvent for unknown channel " + event.getChannel2()); + log.error("Ignored UnlinkEvent for unknown channel " + + event.getChannel2()); return; } - log.info("Unlinking channels " + channel1.getName() + " and " + channel2.getName()); + log.info("Unlinking channels " + channel1.getName() + " and " + + channel2.getName()); synchronized (channel1) { channel1.setLinkedChannel(null); @@ -522,7 +601,64 @@ public class DefaultAsteriskManager impl { Channel channel = (Channel) channels.get(event.getUniqueId()); - log.info("Renaming channel '" + channel.getName() + "' to '" + event.getNewname() + "'"); + log.info("Renaming channel '" + channel.getName() + "' to '" + + event.getNewname() + "'"); channel.setName(event.getNewname()); } + + protected void handleOriginateSuccessEvent(OriginateSuccessEvent event) + { + log.debug("Got OriginateSuccess Event" + event); + // see if there is a call registered for this actionid + synchronized (calls) + { + Call call = (Call) calls.get(event.getActionId()); + log.debug("Found a call waiting for this OriginateSuccess event"); + // update the call and notify that it is ready + if (call != null) + { + synchronized (call) + { + Channel channel; + + calls.remove(call); + + channel = (Channel) channels.get(event.getUniqueId()); + call.setUniqueId(event.getUniqueId()); + call.setChannel(channel); + call.setStartTime(event.getDateReceived()); + call.setReason(event.getReason()); + call.notify(); + } + } + } + } + + protected void handleOriginateFailureEvent(OriginateFailureEvent event) + { + // see if there is a call registered for this actionid + synchronized (calls) + { + Call call = (Call) calls.get(event.getActionId()); + + // update the call and notify that it is ready + if (call != null) + { + synchronized (call) + { + Channel channel; + + calls.remove(call); + + channel = (Channel) channels.get(event.getUniqueId()); + call.setUniqueId(event.getUniqueId()); + call.setChannel(channel); + call.setStartTime(event.getDateReceived()); + call.setEndTime(event.getDateReceived()); + call.setReason(event.getReason()); + call.notify(); + } + } + } + } } Index: AsteriskManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/AsteriskManager.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- AsteriskManager.java 23 Feb 2005 22:50:57 -0000 1.4 +++ AsteriskManager.java 22 Jun 2005 18:27:12 -0000 1.5 @@ -19,8 +19,6 @@ package net.sf.asterisk.manager; import java.io.IOException; import java.util.Map; -import net.sf.asterisk.manager.action.OriginateAction; - /** * @author srt * @version $Id$ @@ -30,13 +28,13 @@ public interface AsteriskManager /** * Generates an outgoing call. * - * @param originateAction conatins the details of the call to originate - * @return the unique id of the created channel (this one is also found in the cdr) + * @param originate conatins the details of the call to originate + * @return a Call object representing the originated call * * @throws TimeoutException if the originated call is not answered in time * @throws IOException if the action cannot be sent to the asterisk server */ - String originateCall(OriginateAction originateAction) throws TimeoutException, IOException; + public Call originateCall(Originate originate) throws TimeoutException, IOException, Exception; /** * Returns a Map of active channels.<br> Index: MultiAsterisksManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/MultiAsterisksManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- MultiAsterisksManager.java 31 Mar 2005 22:29:50 -0000 1.3 +++ MultiAsterisksManager.java 22 Jun 2005 18:27:12 -0000 1.4 @@ -456,7 +456,7 @@ public class MultiAsterisksManager imple * * @see net.sf.asterisk.manager.AsteriskManager#originateCall(net.sf.asterisk.manager.action.OriginateAction) */ - public String originateCall(OriginateAction originateAction) throws TimeoutException, IOException + public Call originateCall(Originate originate) throws TimeoutException, IOException { // TODO Auto-generated method stub return null; |
From: Stefan R. <sr...@us...> - 2005-06-08 02:21:41
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11889/src/java/net/sf/asterisk/manager/event Modified Files: OriginateEvent.java OriginateFailureEvent.java OriginateSuccessEvent.java Log Message: Moved uniqueId and reason attributes to OriginateEvent Index: OriginateEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event/OriginateEvent.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- OriginateEvent.java 23 Feb 2005 22:50:58 -0000 1.2 +++ OriginateEvent.java 8 Jun 2005 02:21:31 -0000 1.3 @@ -20,7 +20,6 @@ package net.sf.asterisk.manager.event; * Abstract base class for events triggered in response to an OriginateAction. * * @see net.sf.asterisk.manager.action.OriginateAction - * * @author srt * @version $Id$ */ @@ -29,6 +28,8 @@ public abstract class OriginateEvent ext private String channel; private String context; private String exten; + private String uniqueId; + private Integer reason; /** * @param source @@ -40,7 +41,6 @@ public abstract class OriginateEvent ext /** * Returns the name of the channel to connect to the outgoing call. - * */ public String getChannel() { @@ -86,4 +86,24 @@ public abstract class OriginateEvent ext { this.exten = exten; } + + public Integer getReason() + { + return reason; + } + + public void setReason(Integer reason) + { + this.reason = reason; + } + + public String getUniqueId() + { + return uniqueId; + } + + public void setUniqueId(String uniqueId) + { + this.uniqueId = uniqueId; + } } Index: OriginateFailureEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event/OriginateFailureEvent.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- OriginateFailureEvent.java 23 Feb 2005 22:50:58 -0000 1.2 +++ OriginateFailureEvent.java 8 Jun 2005 02:21:31 -0000 1.3 @@ -17,10 +17,10 @@ package net.sf.asterisk.manager.event; /** - * An OriginateFailureEvent is triggered when the execution of an OriginateAction failed. + * An OriginateFailureEvent is triggered when the execution of an + * OriginateAction failed. * * @see net.sf.asterisk.manager.action.OriginateAction - * * @author srt * @version $Id$ */ Index: OriginateSuccessEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event/OriginateSuccessEvent.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- OriginateSuccessEvent.java 23 Feb 2005 22:50:58 -0000 1.2 +++ OriginateSuccessEvent.java 8 Jun 2005 02:21:31 -0000 1.3 @@ -17,10 +17,10 @@ package net.sf.asterisk.manager.event; /** - * An OriginateSuccessEvent is triggered when the execution of an OriginateAction succeeded. + * An OriginateSuccessEvent is triggered when the execution of an + * OriginateAction succeeded. * * @see net.sf.asterisk.manager.action.OriginateAction - * * @author srt * @version $Id$ */ |
From: Stefan R. <sr...@us...> - 2005-06-07 23:36:25
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16627/src/java/net/sf/asterisk/manager/impl Modified Files: ManagerReaderImpl.java Log Message: Added patch for command action response from Derrick Shields Index: ManagerReaderImpl.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/impl/ManagerReaderImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- ManagerReaderImpl.java 23 Apr 2005 22:56:31 -0000 1.5 +++ ManagerReaderImpl.java 7 Jun 2005 23:36:15 -0000 1.6 @@ -146,14 +146,32 @@ public class ManagerReaderImpl implement { CommandResponse commandResponse = new CommandResponse(); - if (!commandResult.isEmpty() && ((String) commandResult.get(0)).startsWith("ActionID")) + for (int crIdx = 0; crIdx < commandResult.size(); crIdx++) { - String tmp = (String) commandResult.get(0); - int delimiterIndex = tmp.indexOf(":"); - if (delimiterIndex > 0 && tmp.length() > delimiterIndex + 2) + String[] crNVPair = ((String) commandResult.get(crIdx)).split(" *: *", 2); + + if (crNVPair[0].equals("ActionID")) { - commandResult.remove(0); - commandResponse.setActionId(tmp.substring(delimiterIndex + 2)); + // Remove the command response nvpair from the + // command result array and decrement index so we + // don't skip the "new" current line + commandResult.remove(crIdx--); + + // Register the action id with the command result + commandResponse.setActionId(crNVPair[1]); + } + else if (crNVPair[0].equals("Privilege")) + { + // Remove the command response nvpair from the + // command result array and decrement index so we + // don't skip the "new" current line + commandResult.remove(crIdx--); + } + else + { + // Didn't find a name:value pattern, so we're now in the + // command results. Stop processing the nv pairs. + break; } } commandResponse.setResponse("Follows"); |
From: Stefan R. <sr...@us...> - 2005-05-21 23:06:15
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13674/src/java/net/sf/asterisk/manager/event Modified Files: ManagerEvent.java Log Message: Added note about the possibility of multiple privileges to javadoc Index: ManagerEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event/ManagerEvent.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- ManagerEvent.java 21 May 2005 21:22:27 -0000 1.4 +++ ManagerEvent.java 21 May 2005 23:06:04 -0000 1.5 @@ -80,7 +80,8 @@ public abstract class ManagerEvent exten /** * Returns the AMI authorization class of this event.<br> - * This is one of system, call, log, verbose, command, agent or user.<br> + * This is one or more of system, call, log, verbose, command, agent or user. + * Multiple privileges are separated by comma.<br> * Note: This property is not available from Asterisk 1.0 servers. * @since 0.2 */ |
From: Stefan R. <sr...@us...> - 2005-05-21 21:22:36
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29652/src/java/net/sf/asterisk/manager/event Modified Files: ManagerEvent.java Log Message: Added post-1.0 property privilege Index: ManagerEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event/ManagerEvent.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- ManagerEvent.java 13 Mar 2005 11:26:49 -0000 1.3 +++ ManagerEvent.java 21 May 2005 21:22:27 -0000 1.4 @@ -38,6 +38,15 @@ public abstract class ManagerEvent exten */ static final long serialVersionUID = 4299374743315152040L; + /** + * AMI authorization class. + */ + private String privilege; + + /** + * The point in time this event has been received from the Asterisk + * server. + */ private Date dateReceived; /** @@ -50,7 +59,7 @@ public abstract class ManagerEvent exten } /** - * Returns the point in time this event was received from the asterisk + * Returns the point in time this event was received from the Asterisk * server.<br> * Pseudo events that are not directly received from the asterisk server * (for example ConnectEvent and DisconnectEvent) may return @@ -69,12 +78,36 @@ public abstract class ManagerEvent exten this.dateReceived = dateReceived; } + /** + * Returns the AMI authorization class of this event.<br> + * This is one of system, call, log, verbose, command, agent or user.<br> + * Note: This property is not available from Asterisk 1.0 servers. + * @since 0.2 + */ + public String getPrivilege() + { + return privilege; + } + + /** + * Sets the AMI authorization class of this event. + * @since 0.2 + */ + public void setPrivilege(String privilege) + { + this.privilege = privilege; + } + public String toString() { StringBuffer sb; sb = new StringBuffer(getClass().getName() + ": "); sb.append("dateReceived=" + getDateReceived() + "; "); + if (getPrivilege() != null) + { + sb.append("privilege=" + getPrivilege() + "; "); + } // TODO print attributes sb.append("systemHashcode=" + System.identityHashCode(this)); |
From: Stefan R. <sr...@us...> - 2005-05-08 13:22:23
|
Update of /cvsroot/asterisk-java/asterisk-java/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11214/xdocs Modified Files: index.xml Log Message: Added notes about MAGI support and Mobicents to the status section. Index: index.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/index.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -p -r1.15 -r1.16 --- index.xml 8 May 2005 11:59:53 -0000 1.15 +++ index.xml 8 May 2005 13:22:14 -0000 1.16 @@ -57,6 +57,10 @@ from the <a href="http://sourceforge.net/projects/asterisk-java/">sourceforge project page</a>.</p> + <p>The plan for 0.2 includes optional support for David Pollak's + <a href="http://lists.digium.com/pipermail/asterisk-dev/2005-March/010309.html">MAGI</a> + interface (AGI over the Manager API) as soon as it is integrated + into Asterisk's CVS HEAD.</p> <p>Ideas for the future include a stateful higher level API that supports operations like "get list of currently active calls" or "place call" with objects like "Call" or @@ -67,6 +71,13 @@ Telephony API (JTAPI)</a> based on the <a href="http://gjtapi.sourceforge.net/">Generic JTAPI and JCC Project (GJTAPI)</a>.</p> + <p>Another option is to improve Asterisk support in + <a href="http://www.mobicents.org">Mobicents</a> a VoIP + Middleware based on the + <a href="http://java.sun.com/products/jain/article_slee_principles.html">JAIN SLEE</a> + standard. There is already an + <a href="http://mobicents.dev.java.net/servlets/ProjectForumMessageView?messageID=7615&forumID=739">Asterisk RA</a> + available that is based on Asterisk-Java.</p> </subsection> <subsection name="Download"> <p>Official releases and release candidates are available on the <a |
From: Stefan R. <sr...@us...> - 2005-05-08 13:14:27
|
Update of /cvsroot/asterisk-java/asterisk-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9613 Modified Files: project.xml Log Message: Changed name to Asterisk-Java (was asterisk-java) Index: project.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/project.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -p -r1.16 -r1.17 --- project.xml 3 May 2005 16:53:17 -0000 1.16 +++ project.xml 8 May 2005 13:14:18 -0000 1.17 @@ -27,7 +27,7 @@ <report>maven-pmd-plugin</report> </reports> <id>asterisk-java</id> - <name>asterisk-java</name> + <name>Asterisk-Java</name> <currentVersion>0.2-SNAPSHOT</currentVersion> <organization> <name>Stefan Reuter</name> |
From: Stefan R. <sr...@us...> - 2005-05-08 12:39:38
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2495/src/java/net/sf/asterisk/fastagi/command Modified Files: GetDataCommand.java Log Message: Changed GetDataCommand to include timeout and maxDigits only if needed. Index: GetDataCommand.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command/GetDataCommand.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- GetDataCommand.java 11 Mar 2005 23:15:39 -0000 1.3 +++ GetDataCommand.java 8 May 2005 12:39:29 -0000 1.4 @@ -32,6 +32,10 @@ public class GetDataCommand extends AGIC */ private static final long serialVersionUID = 3978141041352128820L; + private static final int DEFAULT_MAX_DIGITS = 1024; + private static final int DEFAULT_TIMEOUT = 0; + + /** * The name of the file to stream. */ @@ -59,8 +63,8 @@ public class GetDataCommand extends AGIC public GetDataCommand(String file) { this.file = file; - this.timeout = 0; - this.maxDigits = 1024; + this.timeout = DEFAULT_TIMEOUT; + this.maxDigits = DEFAULT_MAX_DIGITS; } /** @@ -76,7 +80,7 @@ public class GetDataCommand extends AGIC { this.file = file; this.timeout = timeout; - this.maxDigits = 1024; + this.maxDigits = DEFAULT_MAX_DIGITS; } /** @@ -176,6 +180,17 @@ public class GetDataCommand extends AGIC public String buildCommand() { + if (maxDigits == DEFAULT_MAX_DIGITS) + { + if (timeout == DEFAULT_TIMEOUT) + { + return "GET DATA " + escapeAndQuote(file); + } + else + { + return "GET DATA " + escapeAndQuote(file) + " " + timeout; + } + } return "GET DATA " + escapeAndQuote(file) + " " + timeout + " " + maxDigits; } |
From: Stefan R. <sr...@us...> - 2005-05-08 12:39:38
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2495/src/test/net/sf/asterisk/fastagi/command Added Files: GetDataCommandTest.java Log Message: Changed GetDataCommand to include timeout and maxDigits only if needed. --- NEW FILE: GetDataCommandTest.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; import junit.framework.TestCase; public class GetDataCommandTest extends TestCase { private GetDataCommand getDataCommand; public void testDefault() { getDataCommand = new GetDataCommand("VAR1"); assertEquals("GET DATA \"VAR1\"", getDataCommand.buildCommand()); } public void testSetTimeout() { getDataCommand = new GetDataCommand("VAR1"); getDataCommand.setTimeout(10000); assertEquals(10000, getDataCommand.getTimeout()); assertEquals(1024, getDataCommand.getMaxDigits()); assertEquals("GET DATA \"VAR1\" 10000", getDataCommand.buildCommand()); } public void testSetMaxDigits() { getDataCommand = new GetDataCommand("VAR1"); getDataCommand.setMaxDigits(10); assertEquals(0, getDataCommand.getTimeout()); assertEquals(10, getDataCommand.getMaxDigits()); assertEquals("GET DATA \"VAR1\" 0 10", getDataCommand.buildCommand()); } public void testSetTimeoutAndMaxDigits() { getDataCommand = new GetDataCommand("VAR1"); getDataCommand.setTimeout(10000); getDataCommand.setMaxDigits(20); assertEquals(10000, getDataCommand.getTimeout()); assertEquals(20, getDataCommand.getMaxDigits()); assertEquals("GET DATA \"VAR1\" 10000 20", getDataCommand.buildCommand()); } } |
From: Stefan R. <sr...@us...> - 2005-05-08 12:00:09
|
Update of /cvsroot/asterisk-java/asterisk-java/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24483/xdocs Modified Files: index.xml patch.xml tutorial.xml Log Message: Butified documentation. Index: index.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/index.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -p -r1.14 -r1.15 --- index.xml 8 May 2005 11:18:08 -0000 1.14 +++ index.xml 8 May 2005 11:59:53 -0000 1.15 @@ -53,7 +53,7 @@ License, Version 2.0</a>.</p> </subsection> <subsection name="Status"> - <p>The first release of Asterisk-Java has been realeased and is available + <p>Asterisk-Java 0.1 has been realeased and is available from the <a href="http://sourceforge.net/projects/asterisk-java/">sourceforge project page</a>.</p> Index: patch.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/patch.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- patch.xml 24 Apr 2005 15:58:07 -0000 1.3 +++ patch.xml 8 May 2005 11:59:53 -0000 1.4 @@ -26,7 +26,7 @@ <body> <section name="How To Create and Submit a Patch"> - <p>This documents how to create and submit patches for Asterisk-java.</p> + <p>This documents how to create and submit patches for Asterisk-Java.</p> <subsection name="Introduction"> <p>A patch is exactly what the word says: a small piece of code used to @@ -63,7 +63,7 @@ <subsection name="Sending a Patch"> <p>The preferred way to submit a patch is via the - <a href="mail-lists.html">Asterisk-java Developer List</a>. + <a href="mail-lists.html">Asterisk-Java Developer List</a>. The patch can be reviewed there in public and other suggestions can be discussed.</p> </subsection> Index: tutorial.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/tutorial.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -p -r1.11 -r1.12 --- tutorial.xml 20 Apr 2005 23:56:41 -0000 1.11 +++ tutorial.xml 8 May 2005 11:59:53 -0000 1.12 @@ -41,7 +41,7 @@ Asterisk or on a seperate machine) that is only started once and serves AGI scripts until it is shut down. Combined with Java's multithreading support you can build pretty fast AGI scripts using this protocol.</p> - <p>Asterisk-java helps you with running your Java based AGI scripts by providing + <p>Asterisk-Java helps you with running your Java based AGI scripts by providing a container that recives connections from the Asterisk server, parses the request and calls your scripts mapped to the called URL.</p> <subsection name="Hello AGI!"> @@ -85,7 +85,7 @@ $ ... exten => 1300,1,Agi(agi://localhost/hello.agi) ]]></source> - <p>Replace localhost with the hostname of the machine that runs Asterisk-java.</p> + <p>Replace localhost with the hostname of the machine that runs Asterisk-Java.</p> <p>Be sure to reload Asterisk for this change to take effect. You can do so by executing <code>extensions reload</code> on the Asterisk CLI.</p> <p>Now you must map the script name <code>hello.agi</code> to the HelloAGIScript |
From: Stefan R. <sr...@us...> - 2005-05-08 11:18:21
|
Update of /cvsroot/asterisk-java/asterisk-java/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8889/xdocs Modified Files: index.xml Log Message: Added link to .net port Index: index.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/index.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -p -r1.13 -r1.14 --- index.xml 15 Apr 2005 04:47:00 -0000 1.13 +++ index.xml 8 May 2005 11:18:08 -0000 1.14 @@ -24,9 +24,9 @@ </properties> <meta name="keywords" content="Asterisk,asterisk,Java,java,Manager API,FastAGI,AGI"/> <body> - <section name="Asterisk Java"> - <subsection name="What is Asterisk-java?"> - <p>The Asterisk-java package consists of a set of Java classes + <section name="Asterisk-Java"> + <subsection name="What is Asterisk-Java?"> + <p>The Asterisk-Java package consists of a set of Java classes that allow you to easily build Java applications that interact with an <a href="http://www.asterisk.org/">Asterisk PBX Server</a>. Asterisk-java supports both interfaces that Asterisk provides for this scenario: @@ -48,14 +48,12 @@ href="apidocs/index.html">javadocs</a>.</p> </subsection> <subsection name="License"> - <p>Asterisk-java is provided under the terms of the <a + <p>Asterisk-Java is provided under the terms of the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> </subsection> <subsection name="Status"> - <p>I am currently preparing the first release of Asterisk-java. - It will probably be available by the end of april. - Meanwhile you can try out a release candidate available + <p>The first release of Asterisk-Java has been realeased and is available from the <a href="http://sourceforge.net/projects/asterisk-java/">sourceforge project page</a>.</p> @@ -77,8 +75,8 @@ <p>You can also download a <a href="http://maven.reucon.com/maven/asterisk-java/distributions/">snapshot</a>.</p> <p>Please feel free to provide any feedback or ask for support via the - <a href="mail-lists.html">Asterisk-java user's mailing list</a>.</p> - <p>Asterisk-java is also available via cvs from sourcforge:</p> + <a href="mail-lists.html">Asterisk-Java user's mailing list</a>.</p> + <p>Asterisk-Java is also available via cvs from sourcforge:</p> <source><![CDATA[ cvs -d:pserver:ano...@cv...:/cvsroot/asterisk-java login cvs -z3 -d:pserver:ano...@cv...:/cvsroot/asterisk-java co asterisk-java @@ -87,6 +85,12 @@ cvs -z3 -d:pserver:ano...@cv...urcef press the Enter key.</p> </subsection> <subsection name="Related Projects"> + <p><a href="http://www3.mb.sympatico.ca/~chadk/">Asterisk-Java for Mono/.NET</a> + is a port of Asterisk-Java to C# for Mono, Microsoft's .NET + Framework and anything else that implements the basic portions + of the framework required to use this. + It's based on a pre-0.1 snapshot of Asterisk-Java and available under + Apache License.</p> <p><a href="http://tanesha.net/Wiki/JastAgi.html">Jast Agi</a> is another toolkit for writing Java applications that connect to Asterisk using the FastAGI protocol. The lastest version introduces @@ -99,7 +103,7 @@ cvs -z3 -d:pserver:ano...@cv...urcef <p><a href="http://sourceforge.net/projects/jasterisk/">JAsterisk</a> is a set of JNI classes providing direct access to Asterisk PBX functionality from Java. It is not a socket-level - interface to Asterisk (like asterisk-java) but a true Java-Asterisk + interface to Asterisk (like Asterisk-Java) but a true Java-Asterisk integration at the Thread level. Available under GNU General Public License.</p> </subsection> <subsection name="Contact"> <p>You can reach me at <code>srt</code> |
From: Stefan R. <sr...@us...> - 2005-05-03 21:08:03
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi/reply/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20915/src/test/net/sf/asterisk/fastagi/reply/impl Modified Files: AGIReplyImplTest.java Log Message: Fixed AGIReply construction when processing replies like '200 result= (timeout)' Index: AGIReplyImplTest.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi/reply/impl/AGIReplyImplTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- AGIReplyImplTest.java 15 Apr 2005 04:47:00 -0000 1.1 +++ AGIReplyImplTest.java 3 May 2005 21:07:52 -0000 1.2 @@ -149,4 +149,16 @@ public class AGIReplyImplTest extends Te "Deletes an entry in the Asterisk database for a given family and key. Returns 1 if succesful, 0 otherwise", reply.getUsage()); } + + public void testBuildReplyWithLeadingSpace() + { + AGIReplyImpl reply; + + lines.add("200 result= (timeout)"); + + reply = new AGIReplyImpl(lines); + + assertEquals("Incorrect status", AGIReplyImpl.SC_SUCCESS, reply.getStatus()); + assertEquals("Incorrect extra", "timeout", reply.getExtra()); + } } |
From: Stefan R. <sr...@us...> - 2005-05-03 21:08:02
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/reply/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20915/src/java/net/sf/asterisk/fastagi/reply/impl Modified Files: AGIReplyImpl.java Log Message: Fixed AGIReply construction when processing replies like '200 result= (timeout)' Index: AGIReplyImpl.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/reply/impl/AGIReplyImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- AGIReplyImpl.java 15 Apr 2005 04:47:01 -0000 1.1 +++ AGIReplyImpl.java 3 May 2005 21:07:52 -0000 1.2 @@ -33,11 +33,11 @@ public class AGIReplyImpl implements Ser private static final Pattern STATUS_PATTERN = Pattern .compile("^(\\d{3})[ -]"); private static final Pattern RESULT_PATTERN = Pattern - .compile("^200 result=(\\S+)"); + .compile("^200 result= *(\\S+)"); private static final Pattern PARENTHESIS_PATTERN = Pattern - .compile("^200 result=\\S+ \\((.*)\\)"); + .compile("^200 result=\\S* +\\((.*)\\)"); private static final Pattern ADDITIONAL_ATTRIBUTES_PATTERN = Pattern - .compile("^200 result=\\S+ (\\(.*\\) )?(.+)$"); + .compile("^200 result=\\S* +(\\(.*\\) )?(.+)$"); private static final Pattern ADDITIONAL_ATTRIBUTE_PATTERN = Pattern .compile("(\\S+)=(\\S+)"); private static final Pattern SYNOPSIS_PATTERN = Pattern |
From: Stefan R. <sr...@us...> - 2005-05-03 16:53:28
|
Update of /cvsroot/asterisk-java/asterisk-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22867 Modified Files: project.xml Log Message: Changed current version to 0.2-SNAPSHOT Index: project.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/project.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -p -r1.15 -r1.16 --- project.xml 30 Apr 2005 17:00:41 -0000 1.15 +++ project.xml 3 May 2005 16:53:17 -0000 1.16 @@ -28,7 +28,7 @@ </reports> <id>asterisk-java</id> <name>asterisk-java</name> - <currentVersion>0.1</currentVersion> + <currentVersion>0.2-SNAPSHOT</currentVersion> <organization> <name>Stefan Reuter</name> <url>http://sourceforge.net/projects/asterisk-java/</url> @@ -53,8 +53,8 @@ </repository> <versions> <version> - <id>0.1-SNAPSHOT</id> - <name>0.1-SNAPSHOT</name> + <id>0.2-SNAPSHOT</id> + <name>0.2-SNAPSHOT</name> <tag>HEAD</tag> </version> <version> |
From: Stefan R. <sr...@us...> - 2005-05-03 16:51:11
|
Update of /cvsroot/asterisk-java/asterisk-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22083 Added Files: ANNOUNCEMENT Log Message: Added announcement for 0.1 release --- NEW FILE: ANNOUNCEMENT --- ANNOUNCEMENT: Asterisk-java 0.1 released Asterisk-java 0.1 a Java control for the Asterisk PBX has been released. The Asterisk-java package consists of a set of Java classes that allow you to easily build Java applications that interact with an Asterisk PBX Server. Asterisk-java supports both interfaces that Asterisk provides for this scenario: The FastAGI protocol and the Manager API. The FastAGI implementation supports all commands currently available from Asterisk. The Manager API implementation supports receiving events from the Asterisk server (e.g. call progess, registered peers, channel state) and sending actions to Asterisk (e.g. originate call, agent login/logoff, start/stop voice recording). Asterisk-java is available under Apache 2.0 license at http://asterisk-java.sourceforge.net |
From: Stefan R. <sr...@us...> - 2005-04-30 17:00:51
|
Update of /cvsroot/asterisk-java/asterisk-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19727 Modified Files: project.xml Log Message: [maven-scm-plugin] prepare release 0.1 Index: project.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/project.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -p -r1.14 -r1.15 --- project.xml 20 Apr 2005 18:22:13 -0000 1.14 +++ project.xml 30 Apr 2005 17:00:41 -0000 1.15 @@ -28,7 +28,7 @@ </reports> <id>asterisk-java</id> <name>asterisk-java</name> - <currentVersion>0.1-SNAPSHOT</currentVersion> + <currentVersion>0.1</currentVersion> <organization> <name>Stefan Reuter</name> <url>http://sourceforge.net/projects/asterisk-java/</url> @@ -62,6 +62,11 @@ <name>0.1-rc1</name> <tag>RC_0_1_1</tag> </version> + <version> + <id>0.1</id> + <name>0.1</name> + <tag>REL_0_1</tag> + </version> </versions> <mailingLists> <mailingList> |
From: Stefan R. <sr...@us...> - 2005-04-30 16:45:23
|
Update of /cvsroot/asterisk-java/asterisk-java/src/integrationtest/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11223/src/integrationtest/net/sf/asterisk/manager Modified Files: TestDefaultAsteriskManager.java Added Files: AsteriskManagerTestCase.java SofthangupTest.java Log Message: Refactored integration tests --- NEW FILE: AsteriskManagerTestCase.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.manager; import junit.framework.TestCase; public class AsteriskManagerTestCase extends TestCase { protected DefaultAsteriskManager manager; protected DefaultManagerConnection managerConnection; public void setUp() throws Exception { managerConnection = new DefaultManagerConnection(); managerConnection.setHostname("deprecated"); managerConnection.setUsername("manager"); managerConnection.setPassword("obelisk"); manager = new DefaultAsteriskManager(); manager.setManagerConnection(managerConnection); manager.initialize(); } public void tearDown() throws Exception { managerConnection.logoff(); } } --- NEW FILE: SofthangupTest.java --- /* * (c) 2004 Stefan Reuter * * Created on Oct 28, 2004 */ package net.sf.asterisk.manager; import net.sf.asterisk.manager.action.OriginateAction; import net.sf.asterisk.manager.response.ManagerResponse; /** * @author srt * @version $Id: SofthangupTest.java,v 1.1 2005/04/30 16:45:15 srt Exp $ */ public class SofthangupTest extends AsteriskManagerTestCase { public void testSofthangup() throws Exception { OriginateAction originate; originate = new OriginateAction(); originate.setChannel("Local/1310"); originate.setContext("default"); originate.setExten("1340"); originate.setPriority(new Integer(1)); ManagerResponse response = managerConnection.sendAction(originate); System.out.println("Response: " + response); Thread.sleep(10000); } } Index: TestDefaultAsteriskManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/integrationtest/net/sf/asterisk/manager/TestDefaultAsteriskManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- TestDefaultAsteriskManager.java 13 Mar 2005 11:39:06 -0000 1.1 +++ TestDefaultAsteriskManager.java 30 Apr 2005 16:45:15 -0000 1.2 @@ -5,32 +5,15 @@ */ package net.sf.asterisk.manager; -import junit.framework.TestCase; /** * @author srt * @version $Id$ */ -public class TestDefaultAsteriskManager extends TestCase +public class TestDefaultAsteriskManager extends AsteriskManagerTestCase { - protected DefaultAsteriskManager getDefaultManager() - { - DefaultAsteriskManager dm = new DefaultAsteriskManager(); - DefaultManagerConnection dmc = new DefaultManagerConnection(); - dmc.setHostname("deprecated"); - dmc.setUsername("manager"); - dmc.setPassword("obelisk"); - dm.setManagerConnection(dmc); - - return dm; - } - public void testInit() throws Exception { - DefaultAsteriskManager dm = getDefaultManager(); - - dm.initialize(); - try { Thread.sleep(30000); @@ -39,6 +22,6 @@ public class TestDefaultAsteriskManager { } - System.out.println(dm.getChannels()); + System.out.println(manager.getChannels()); } } |
From: Stefan R. <sr...@us...> - 2005-04-24 15:58:15
|
Update of /cvsroot/asterisk-java/asterisk-java/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8995/xdocs Modified Files: patch.xml Log Message: Added intro sentence Index: patch.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/patch.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- patch.xml 24 Apr 2005 15:46:10 -0000 1.2 +++ patch.xml 24 Apr 2005 15:58:07 -0000 1.3 @@ -25,6 +25,9 @@ <meta name="keywords" content="Asterisk,asterisk,Java,java,Manager API,FastAGI,AGI"/> <body> <section name="How To Create and Submit a Patch"> + + <p>This documents how to create and submit patches for Asterisk-java.</p> + <subsection name="Introduction"> <p>A patch is exactly what the word says: a small piece of code used to repair a breach. It is normally a plain text file containing only |
From: Stefan R. <sr...@us...> - 2005-04-24 15:49:02
|
Update of /cvsroot/asterisk-java/asterisk-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5331 Modified Files: README Log Message: Added reference to tutorial Index: README =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/README,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- README 24 Apr 2005 15:45:21 -0000 1.1 +++ README 24 Apr 2005 15:48:26 -0000 1.2 @@ -16,3 +16,5 @@ recording). A complete list of the available events and actions is available in the javadocs. + +See docs/tutorial.html for examples. \ No newline at end of file |
From: Stefan R. <sr...@us...> - 2005-04-24 15:47:20
|
Update of /cvsroot/asterisk-java/asterisk-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5055 Modified Files: ChangeLog Log Message: Added accessors for raw attributes in ManagerResponse Index: ChangeLog =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/ChangeLog,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- ChangeLog 24 Apr 2005 15:45:21 -0000 1.1 +++ ChangeLog 24 Apr 2005 15:47:11 -0000 1.2 @@ -1,5 +1,6 @@ asterisk-java 0.1 + * Added accessors for raw attributes in ManagerResponse * Fixed bug in action id creation * Changed logging to use either log4j or java.util.logging * Fixed ExecCommand |