diff --git a/src/main/java/org/ice4j/ice/Agent.java b/src/main/java/org/ice4j/ice/Agent.java index eb62b6b..f993b67 100644 --- a/src/main/java/org/ice4j/ice/Agent.java +++ b/src/main/java/org/ice4j/ice/Agent.java @@ -681,9 +681,9 @@ public class Agent */ public boolean isOver() { - return state == IceProcessingState.COMPLETED - || state == IceProcessingState.TERMINATED - || state == IceProcessingState.FAILED; + IceProcessingState state = getState(); + + return (state != null) && state.isOver(); } /** diff --git a/src/main/java/org/ice4j/ice/IceProcessingState.java b/src/main/java/org/ice4j/ice/IceProcessingState.java index 3de46b9..53aeb6d 100644 --- a/src/main/java/org/ice4j/ice/IceProcessingState.java +++ b/src/main/java/org/ice4j/ice/IceProcessingState.java @@ -35,6 +35,7 @@ package org.ice4j.ice; * refer to with "Terminated". * * @author Emil Ivov + * @author Lyubomir Marinov */ public enum IceProcessingState { @@ -99,6 +100,21 @@ public enum IceProcessingState return stateName; } + /** + * Determines whether an {@link Agent} in this state has finished its ICE + * processing. + * + * @return {@code true} if an {@code Agent} in this state has finished its + * ICE processing; otherwise, {@code false} + */ + public boolean isOver() + { + return + COMPLETED.equals(this) + || FAILED.equals(this) + || TERMINATED.equals(this); + } + /** * Returns true iff the state is one in which a connection * has been established, that is either COMPLETED or