diff --git a/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java b/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java index cc68d067..5e89649b 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java @@ -304,7 +304,9 @@ public abstract class EndPoint { } /** - * Closes all connections ONLY (keeps the server/client running) + * Closes all connections ONLY (keeps the server/client running). + *
+ * This is used, for example, when reconnecting to a server. The server should ALWAYS use STOP. */ public void close() { // give a chance to other threads. @@ -328,7 +330,7 @@ public abstract class EndPoint { /** * Safely closes all associated resources/threads/connections */ - public final void stop() { + public void stop() { // check to make sure we are in our OWN thread, otherwise, this thread will never exit -- because it will wait indefinitely // for itself to finish (since it blocks itself). // This occurs when calling stop from within a listener callback. @@ -442,7 +444,7 @@ public abstract class EndPoint { /** * Extra actions to perform when stopping this endpoint. */ - protected void stopExtraActions() { + void stopExtraActions() { } public String getName() { diff --git a/Dorkbox-Network/src/dorkbox/network/connection/EndPointWithSerialization.java b/Dorkbox-Network/src/dorkbox/network/connection/EndPointWithSerialization.java index 4da3c8e2..ad34b30d 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/EndPointWithSerialization.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/EndPointWithSerialization.java @@ -5,6 +5,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import org.bouncycastle.crypto.params.ECPrivateKeyParameters; import org.bouncycastle.crypto.params.ECPublicKeyParameters; @@ -23,6 +24,7 @@ import dorkbox.network.connection.wrapper.ChannelWrapper; import dorkbox.network.pipeline.KryoEncoder; import dorkbox.network.pipeline.KryoEncoderCrypto; import dorkbox.network.rmi.RmiBridge; +import dorkbox.network.util.EndpointTool; import dorkbox.network.util.KryoSerializationManager; import dorkbox.network.util.SerializationManager; import dorkbox.network.util.exceptions.InitializationException; @@ -228,6 +230,8 @@ public abstract class EndPointWithSerialization extends EndPoint { /** * Closes all connections ONLY (keeps the server/client running) + *
+ * This is used, for example, when reconnecting to a server. The server should ALWAYS use STOP.
*/
@Override
public void close() {
@@ -241,7 +245,60 @@ public abstract class EndPointWithSerialization extends EndPoint {
* Extra actions to perform when stopping this endpoint.
*/
@Override
- protected void stopExtraActions() {
+ final void stopExtraActions() {
this.connectionManager.stop();
}
+
+ ConcurrentHashMap