Changed debug output for client connections
This commit is contained in:
@@ -47,7 +47,7 @@ public class NetServer extends Module{
|
|||||||
return;
|
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 player = new Player();
|
||||||
player.clientid = id;
|
player.clientid = id;
|
||||||
@@ -93,6 +93,7 @@ public class NetServer extends Module{
|
|||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
player.add();
|
player.add();
|
||||||
|
Log.info("&y{0} has connected.", player.name);
|
||||||
netCommon.sendMessage("[accent]" + player.name + " has connected.");
|
netCommon.sendMessage("[accent]" + player.name + " has connected.");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -104,6 +105,7 @@ public class NetServer extends Module{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.info("&y{0} has disconnected.", player.name);
|
||||||
netCommon.sendMessage("[accent]" + player.name + " has disconnected.");
|
netCommon.sendMessage("[accent]" + player.name + " has disconnected.");
|
||||||
player.remove();
|
player.remove();
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public class KryoRegistrator {
|
|||||||
public static final int fakeLagAmount = 500;
|
public static final int fakeLagAmount = 500;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
|
Log.set(Log.LEVEL_ERROR);
|
||||||
|
|
||||||
Log.setLogger(new Logger(){
|
Log.setLogger(new Logger(){
|
||||||
public void log (int level, String category, String message, Throwable ex) {
|
public void log (int level, String category, String message, Throwable ex) {
|
||||||
StringBuilder builder = new StringBuilder(256);
|
StringBuilder builder = new StringBuilder(256);
|
||||||
@@ -26,7 +28,7 @@ public class KryoRegistrator {
|
|||||||
if(headless)
|
if(headless)
|
||||||
builder.append(ColorCodes.BLUE);
|
builder.append(ColorCodes.BLUE);
|
||||||
|
|
||||||
builder.append("Net: ");
|
builder.append("Net Error: ");
|
||||||
|
|
||||||
builder.append(message);
|
builder.append(message);
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ public class KryoServer implements ServerProvider {
|
|||||||
c.id = kn.id;
|
c.id = kn.id;
|
||||||
c.addressTCP = connection.getRemoteAddressTCP().toString();
|
c.addressTCP = connection.getRemoteAddressTCP().toString();
|
||||||
|
|
||||||
|
Log.info("&bRecieved connection: {0} {1}", c.id, c.addressTCP);
|
||||||
|
|
||||||
connections.add(kn);
|
connections.add(kn);
|
||||||
Gdx.app.postRunnable(() -> Net.handleServerReceived(kn.id, c));
|
Gdx.app.postRunnable(() -> Net.handleServerReceived(kn.id, c));
|
||||||
}
|
}
|
||||||
@@ -80,6 +82,8 @@ public class KryoServer implements ServerProvider {
|
|||||||
Disconnect c = new Disconnect();
|
Disconnect c = new Disconnect();
|
||||||
c.id = k.id;
|
c.id = k.id;
|
||||||
|
|
||||||
|
Log.info("&bLost connection: {0}", k.id);
|
||||||
|
|
||||||
Gdx.app.postRunnable(() -> Net.handleServerReceived(k.id, c));
|
Gdx.app.postRunnable(() -> Net.handleServerReceived(k.id, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,18 +394,22 @@ public class KryoServer implements ServerProvider {
|
|||||||
public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
||||||
Connect connect = new Connect();
|
Connect connect = new Connect();
|
||||||
connect.addressTCP = conn.getRemoteSocketAddress().toString();
|
connect.addressTCP = conn.getRemoteSocketAddress().toString();
|
||||||
Log.info("Websocket connection recieved: {0}", connect.addressTCP);
|
|
||||||
KryoConnection kn = new KryoConnection(lastconnection ++, connect.addressTCP, conn);
|
KryoConnection kn = new KryoConnection(lastconnection ++, connect.addressTCP, conn);
|
||||||
|
|
||||||
|
Log.info("&Recieved web connection: {0} {1}", kn.id, connect.addressTCP);
|
||||||
connections.add(kn);
|
connections.add(kn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
||||||
if (conn == null) return;
|
if (conn == null) return;
|
||||||
|
|
||||||
KryoConnection k = getBySocket(conn);
|
KryoConnection k = getBySocket(conn);
|
||||||
if(k == null) return;
|
if(k == null) return;
|
||||||
|
|
||||||
Disconnect disconnect = new Disconnect();
|
Disconnect disconnect = new Disconnect();
|
||||||
disconnect.id = k.id;
|
disconnect.id = k.id;
|
||||||
|
Log.info("&bLost web connection: {0}", k.id);
|
||||||
Net.handleServerReceived(k.id, disconnect);
|
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));
|
conn.send("---" + Vars.playerGroup.size() + "|" + (Vars.headless ? "Server" : Vars.player.name));
|
||||||
connections.remove(k);
|
connections.remove(k);
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
byte[] out = Base64Coder.decode(message);
|
byte[] out = Base64Coder.decode(message);
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(out);
|
ByteBuffer buffer = ByteBuffer.wrap(out);
|
||||||
Object o = serializer.read(buffer);
|
Object o = serializer.read(buffer);
|
||||||
@@ -428,7 +435,7 @@ public class KryoServer implements ServerProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(WebSocket conn, Exception ex) {
|
public void onError(WebSocket conn, Exception ex) {
|
||||||
Log.info("WS error:");
|
Log.info("WS error: ");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
if(ex instanceof BindException){
|
if(ex instanceof BindException){
|
||||||
Net.closeServer();
|
Net.closeServer();
|
||||||
|
|||||||
Reference in New Issue
Block a user