1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-22 22:07:31 +03:00

Removed servtesting code

This commit is contained in:
Anuken 2018-03-03 10:44:32 -05:00
parent 2122d04f78
commit ba46dacfdc
2 changed files with 28 additions and 21 deletions

View File

@ -4,4 +4,4 @@ version=release
androidBuildCode=328 androidBuildCode=328
name=Mindustry name=Mindustry
code=3.4 code=3.4
build=custom build build=29

View File

@ -34,6 +34,7 @@ import java.net.InetSocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.ClosedSelectorException; import java.nio.channels.ClosedSelectorException;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import static io.anuke.mindustry.Vars.headless; import static io.anuke.mindustry.Vars.headless;
import static io.anuke.mindustry.Vars.state; import static io.anuke.mindustry.Vars.state;
@ -45,6 +46,7 @@ public class KryoServer implements ServerProvider {
final ByteSerializer serializer = new ByteSerializer(); final ByteSerializer serializer = new ByteSerializer();
final ByteBuffer buffer = ByteBuffer.allocate(4096); final ByteBuffer buffer = ByteBuffer.allocate(4096);
final CopyOnWriteArrayList<KryoConnection> connections = new CopyOnWriteArrayList<>(); final CopyOnWriteArrayList<KryoConnection> connections = new CopyOnWriteArrayList<>();
final CopyOnWriteArraySet<Integer> missing = new CopyOnWriteArraySet<>();
final Array<KryoConnection> array = new Array<>(); final Array<KryoConnection> array = new Array<>();
SocketServer webServer; SocketServer webServer;
Thread serverThread; Thread serverThread;
@ -159,6 +161,7 @@ public class KryoServer implements ServerProvider {
public void host(int port) throws IOException { public void host(int port) throws IOException {
lastconnection = 0; lastconnection = 0;
connections.clear(); connections.clear();
missing.clear();
server.bind(port, port); server.bind(port, port);
webServer = new SocketServer(Vars.webPort); webServer = new SocketServer(Vars.webPort);
webServer.start(); webServer.start();
@ -263,27 +266,10 @@ public class KryoServer implements ServerProvider {
public void sendTo(int id, Object object, SendMode mode) { public void sendTo(int id, Object object, SendMode mode) {
NetConnection conn = getByID(id); NetConnection conn = getByID(id);
if(conn == null){ if(conn == null){
Log.info("Failed to find connection with ID {0}!", id); if(!missing.contains(id))
Log.err("KRYONET CONNECTIONS:"); Log.err("Failed to find connection with ID {0}.", id);
for(Connection c : server.getConnections()){ missing.add(id);
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);
return; return;
//throw new RuntimeException("Unable to find connection with ID " + id + "!");
} }
conn.send(object, mode); conn.send(object, mode);
} }
@ -352,6 +338,27 @@ public class KryoServer implements ServerProvider {
return null; 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{ class KryoConnection extends NetConnection{
public final WebSocket socket; public final WebSocket socket;
public final Connection connection; public final Connection connection;