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

Changed debug output for client connections

This commit is contained in:
Anuken 2018-01-31 15:04:46 -05:00
parent d2ee2c57bc
commit 9dd6b9e74b
3 changed files with 16 additions and 5 deletions

View File

@ -47,7 +47,7 @@ public class NetServer extends Module{
return;
}
Log.info("Sending world data to client (ID = {0})", id);
Log.info("Sending data to player '{0}' / {1}", packet.name, id);
Player player = new Player();
player.clientid = id;
@ -93,6 +93,7 @@ public class NetServer extends Module{
if (player == null) return;
player.add();
Log.info("&y{0} has connected.", player.name);
netCommon.sendMessage("[accent]" + player.name + " has connected.");
});
@ -104,6 +105,7 @@ public class NetServer extends Module{
return;
}
Log.info("&y{0} has disconnected.", player.name);
netCommon.sendMessage("[accent]" + player.name + " has disconnected.");
player.remove();

View File

@ -19,6 +19,8 @@ public class KryoRegistrator {
public static final int fakeLagAmount = 500;
static{
Log.set(Log.LEVEL_ERROR);
Log.setLogger(new Logger(){
public void log (int level, String category, String message, Throwable ex) {
StringBuilder builder = new StringBuilder(256);
@ -26,7 +28,7 @@ public class KryoRegistrator {
if(headless)
builder.append(ColorCodes.BLUE);
builder.append("Net: ");
builder.append("Net Error: ");
builder.append(message);

View File

@ -67,6 +67,8 @@ public class KryoServer implements ServerProvider {
c.id = kn.id;
c.addressTCP = connection.getRemoteAddressTCP().toString();
Log.info("&bRecieved connection: {0} {1}", c.id, c.addressTCP);
connections.add(kn);
Gdx.app.postRunnable(() -> Net.handleServerReceived(kn.id, c));
}
@ -80,6 +82,8 @@ public class KryoServer implements ServerProvider {
Disconnect c = new Disconnect();
c.id = k.id;
Log.info("&bLost connection: {0}", k.id);
Gdx.app.postRunnable(() -> Net.handleServerReceived(k.id, c));
}
@ -390,18 +394,22 @@ public class KryoServer implements ServerProvider {
public void onOpen(WebSocket conn, ClientHandshake handshake) {
Connect connect = new Connect();
connect.addressTCP = conn.getRemoteSocketAddress().toString();
Log.info("Websocket connection recieved: {0}", connect.addressTCP);
KryoConnection kn = new KryoConnection(lastconnection ++, connect.addressTCP, conn);
Log.info("&Recieved web connection: {0} {1}", kn.id, connect.addressTCP);
connections.add(kn);
}
@Override
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
if (conn == null) return;
KryoConnection k = getBySocket(conn);
if(k == null) return;
Disconnect disconnect = new Disconnect();
disconnect.id = k.id;
Log.info("&bLost web connection: {0}", k.id);
Net.handleServerReceived(k.id, disconnect);
}
@ -415,7 +423,6 @@ public class KryoServer implements ServerProvider {
conn.send("---" + Vars.playerGroup.size() + "|" + (Vars.headless ? "Server" : Vars.player.name));
connections.remove(k);
}else {
byte[] out = Base64Coder.decode(message);
ByteBuffer buffer = ByteBuffer.wrap(out);
Object o = serializer.read(buffer);
@ -428,7 +435,7 @@ public class KryoServer implements ServerProvider {
@Override
public void onError(WebSocket conn, Exception ex) {
Log.info("WS error:");
Log.info("WS error: ");
ex.printStackTrace();
if(ex instanceof BindException){
Net.closeServer();