asterisk-java-cvs Mailing List for Asterisk-Java Library (Page 98)
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
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Stefan R. <sr...@us...> - 2005-01-31 01:18:22
|
Update of /cvsroot/asterisk-java/asterisk-java/src/net/sf/asterisk/manager/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17184/src/net/sf/asterisk/manager/event Modified Files: ManagerEvent.java Added Files: DisconnectEvent.java ConnectEvent.java Log Message: - added ConnectEvent and DisconnectEvent - DefaultAsteriskManager now refreshes its state after restarting asterisk --- NEW FILE: DisconnectEvent.java --- /* * (c) 2004 Stefan Reuter * * Created on Sep 24, 2004 */ package net.sf.asterisk.manager.event; /** * A DisconnectEvent is triggered when the connection to the asterisk server is lost.<br> * It is a pseudo event not directly related to an asterisk generated event. * * @author srt * @version $Id: DisconnectEvent.java,v 1.1 2005/01/31 01:18:04 srt Exp $ */ public class DisconnectEvent extends ManagerEvent { private static final long serialVersionUID = 3689355411862206518L; /** * @param source */ public DisconnectEvent(Object source) { super(source); } } --- NEW FILE: ConnectEvent.java --- /* * (c) 2004 Stefan Reuter * * Created on Sep 24, 2004 */ package net.sf.asterisk.manager.event; /** * A ConnectEvent is triggered after successful login to the asterisk server.<br> * It is a pseudo event not directly related to an asterisk generated event. * * @author srt * @version $Id: ConnectEvent.java,v 1.1 2005/01/31 01:18:04 srt Exp $ */ public class ConnectEvent extends ManagerEvent { private static final long serialVersionUID = 3257845467831284784L; /** * @param source */ public ConnectEvent(Object source) { super(source); } } Index: ManagerEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/net/sf/asterisk/manager/event/ManagerEvent.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -p -r1.9 -r1.10 --- ManagerEvent.java 29 Sep 2004 15:18:19 -0000 1.9 +++ ManagerEvent.java 31 Jan 2005 01:18:04 -0000 1.10 @@ -40,7 +40,9 @@ public abstract class ManagerEvent exten } /** - * Returns the point in time this event was received from the asterisk server. + * 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 <code>null</code>. */ public Date getDateReceived() { |
From: Stefan R. <sr...@us...> - 2005-01-31 01:18:22
|
Update of /cvsroot/asterisk-java/asterisk-java/src/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17184/src/net/sf/asterisk/manager Modified Files: DefaultManagerConnection.java ManagerConnection.java DefaultAsteriskManager.java Log Message: - added ConnectEvent and DisconnectEvent - DefaultAsteriskManager now refreshes its state after restarting asterisk Index: DefaultManagerConnection.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/net/sf/asterisk/manager/DefaultManagerConnection.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -p -r1.9 -r1.10 --- DefaultManagerConnection.java 23 Oct 2004 07:19:45 -0000 1.9 +++ DefaultManagerConnection.java 31 Jan 2005 01:18:03 -0000 1.10 @@ -24,6 +24,8 @@ import net.sf.asterisk.manager.action.Ch import net.sf.asterisk.manager.action.LoginAction; import net.sf.asterisk.manager.action.LogoffAction; import net.sf.asterisk.manager.action.ManagerAction; +import net.sf.asterisk.manager.event.ConnectEvent; +import net.sf.asterisk.manager.event.DisconnectEvent; import net.sf.asterisk.manager.event.ManagerEvent; import net.sf.asterisk.manager.response.ChallengeResponse; import net.sf.asterisk.manager.response.ManagerError; @@ -174,8 +176,7 @@ public class DefaultManagerConnection im login(defaultTimeout); } - private void login(long timeout) throws IOException, AuthenticationFailedException, - TimeoutException + private void login(long timeout) throws IOException, AuthenticationFailedException, TimeoutException { long timeSpent; ChallengeAction challengeAction; @@ -228,8 +229,7 @@ public class DefaultManagerConnection im { logger.error("Unable to create login key using MD5 Message Digest", 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); @@ -245,6 +245,9 @@ public class DefaultManagerConnection im this.keepAlive = true; logger.info("Successfully logged in"); + + // notify event listeners + dispatchEvent(new ConnectEvent(this)); } private void connect() throws IOException @@ -271,10 +274,10 @@ public class DefaultManagerConnection im logoffAction = new LogoffAction(); sendAction(logoffAction); - + disconnect(); } - + private void disconnect() { if (this.writer != null) @@ -304,8 +307,7 @@ public class DefaultManagerConnection im 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; @@ -326,8 +328,7 @@ 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) @@ -338,8 +339,7 @@ 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; @@ -376,10 +376,10 @@ public class DefaultManagerConnection im this.writer.print(actionString); this.writer.flush(); - logger.debug("Sent action with internalActionId '" + internalActionId + "':\n"+ actionString); + logger.debug("Sent action with internalActionId '" + internalActionId + "':\n" + actionString); } } - + /** * Creates a new unique internal action id based on the hash code of this * connection and a sequence. @@ -452,15 +452,13 @@ 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); @@ -469,7 +467,8 @@ public class DefaultManagerConnection im } 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) @@ -565,6 +564,10 @@ public class DefaultManagerConnection im // clean up at first disconnect(); + // notify event listeners + dispatchEvent(new DisconnectEvent(this)); + + // try to reconnect numTries = 0; while (this.keepAlive) { Index: ManagerConnection.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/net/sf/asterisk/manager/ManagerConnection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- ManagerConnection.java 29 Sep 2004 15:18:21 -0000 1.4 +++ ManagerConnection.java 31 Jan 2005 01:18:04 -0000 1.5 @@ -48,7 +48,7 @@ public interface ManagerConnection * @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". * @@ -99,7 +99,7 @@ public interface ManagerConnection * @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. @@ -109,7 +109,7 @@ public interface ManagerConnection * @see #removeEventHandler(ManagerEventHandler) */ void addEventHandler(ManagerEventHandler eventHandler); - + /** * Unregisters a previously registered event handler.<br> * Does nothing if the given event handler hasn't be been regiered before. Index: DefaultAsteriskManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/net/sf/asterisk/manager/DefaultAsteriskManager.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -p -r1.7 -r1.8 --- DefaultAsteriskManager.java 29 Jan 2005 10:59:57 -0000 1.7 +++ DefaultAsteriskManager.java 31 Jan 2005 01:18:04 -0000 1.8 @@ -17,6 +17,8 @@ import java.util.Map; import net.sf.asterisk.manager.action.OriginateAction; import net.sf.asterisk.manager.action.QueueStatusAction; import net.sf.asterisk.manager.action.StatusAction; +import net.sf.asterisk.manager.event.ConnectEvent; +import net.sf.asterisk.manager.event.DisconnectEvent; import net.sf.asterisk.manager.event.HangupEvent; import net.sf.asterisk.manager.event.LinkEvent; import net.sf.asterisk.manager.event.ManagerEvent; @@ -109,6 +111,16 @@ public class DefaultAsteriskManager impl { System.out.println("received: " + event); + if (event instanceof ConnectEvent) + { + handleConnectEvent((ConnectEvent) event); + } + else if (event instanceof DisconnectEvent) + { + handleDisconnectEvent((DisconnectEvent) event); + } + + // build initial state if not yet initialized, dispatch otherwise. if (!initialized) { if (event instanceof StatusEvent) @@ -219,8 +231,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; } @@ -260,6 +272,45 @@ public class DefaultAsteriskManager impl this.channelsInitialized = true; } + /** + * Resets the internal state when the connection to the asterisk server is lost. + */ + protected void handleDisconnectEvent(DisconnectEvent disconnectEvent) + { + this.channels.clear(); + this.queues.clear(); + this.queuedEvents.clear(); + this.channelsInitialized = false; + //TODO fix detection of queuesInitialized + this.queuesInitialized = true; + this.initialized = false; + } + + /** + * Requests the current state from the asterisk server after the connection to the asterisk + * server is restored. + */ + protected void handleConnectEvent(ConnectEvent connectEvent) + { + try + { + connection.sendAction(new StatusAction()); + } + catch (Exception e) + { + log.error("Unable to request channel status from asterisk server after reconnect.", e); + } + + try + { + connection.sendAction(new QueueStatusAction()); + } + catch (Exception e) + { + log.error("Unable to request queue status from asterisk server after reconnect.", e); + } + } + protected void handleQueueParamsEvent(QueueParamsEvent event) { Queue queue; |
From: Stefan R. <sr...@us...> - 2005-01-29 11:40:06
|
test |