From ba46dacfdc01b41ea5eb9298e6925c3799cd6fbb Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 3 Mar 2018 10:44:32 -0500 Subject: [PATCH] Removed servtesting code --- core/assets/version.properties | 2 +- kryonet/src/io/anuke/kryonet/KryoServer.java | 47 +++++++++++--------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/core/assets/version.properties b/core/assets/version.properties index 93cac6d10d..592935ec0e 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -4,4 +4,4 @@ version=release androidBuildCode=328 name=Mindustry code=3.4 -build=custom build +build=29 diff --git a/kryonet/src/io/anuke/kryonet/KryoServer.java b/kryonet/src/io/anuke/kryonet/KryoServer.java index 8ec335ec95..cc765eaa40 100644 --- a/kryonet/src/io/anuke/kryonet/KryoServer.java +++ b/kryonet/src/io/anuke/kryonet/KryoServer.java @@ -34,6 +34,7 @@ import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.nio.channels.ClosedSelectorException; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CopyOnWriteArraySet; import static io.anuke.mindustry.Vars.headless; import static io.anuke.mindustry.Vars.state; @@ -45,6 +46,7 @@ public class KryoServer implements ServerProvider { final ByteSerializer serializer = new ByteSerializer(); final ByteBuffer buffer = ByteBuffer.allocate(4096); final CopyOnWriteArrayList connections = new CopyOnWriteArrayList<>(); + final CopyOnWriteArraySet missing = new CopyOnWriteArraySet<>(); final Array array = new Array<>(); SocketServer webServer; Thread serverThread; @@ -159,6 +161,7 @@ public class KryoServer implements ServerProvider { public void host(int port) throws IOException { lastconnection = 0; connections.clear(); + missing.clear(); server.bind(port, port); webServer = new SocketServer(Vars.webPort); webServer.start(); @@ -263,27 +266,10 @@ public class KryoServer implements ServerProvider { public void sendTo(int id, Object object, SendMode mode) { NetConnection conn = getByID(id); if(conn == null){ - Log.info("Failed to find connection with ID {0}!", id); - Log.err("KRYONET CONNECTIONS:"); - for(Connection c : server.getConnections()){ - NetConnection k = getByKryoID(c.getID()); - Log.err(" - Kryonet connection / ID {0} / IP {1} / NetConnection ID {2}", - c.getID(), c.getRemoteAddressTCP().getAddress().getHostAddress(), k == null ? "NOT FOUND" : k.id); - } - Log.err("NET CONNECTIONS:"); - for(NetConnection c : connections){ - Log.err(" - NetConnection / ID {0} / IP {1}", c.id, c.address); - } - - Log.err("\nSTACK TRACE:"); - - StackTraceElement[] e = Thread.getAllStackTraces().get(Thread.currentThread()); - for(StackTraceElement s : e){ - Log.err("- {0}", s); - } - System.exit(-1); + if(!missing.contains(id)) + Log.err("Failed to find connection with ID {0}.", id); + missing.add(id); return; - //throw new RuntimeException("Unable to find connection with ID " + id + "!"); } conn.send(object, mode); } @@ -352,6 +338,27 @@ public class KryoServer implements ServerProvider { return null; } + void throwErrorAndExit(){ + Log.err("KRYONET CONNECTIONS:"); + for(Connection c : server.getConnections()){ + NetConnection k = getByKryoID(c.getID()); + Log.err(" - Kryonet connection / ID {0} / IP {1} / NetConnection ID {2}", + c.getID(), c.getRemoteAddressTCP().getAddress().getHostAddress(), k == null ? "NOT FOUND" : k.id); + } + Log.err("NET CONNECTIONS:"); + for(NetConnection c : connections){ + Log.err(" - NetConnection / ID {0} / IP {1}", c.id, c.address); + } + + Log.err("\nSTACK TRACE:"); + + StackTraceElement[] e = Thread.getAllStackTraces().get(Thread.currentThread()); + for(StackTraceElement s : e){ + Log.err("- {0}", s); + } + System.exit(-1); + } + class KryoConnection extends NetConnection{ public final WebSocket socket; public final Connection connection;