Slightly more informative D/C messages
This commit is contained in:
@@ -107,7 +107,17 @@ public class NetClient implements ApplicationListener{
|
||||
|
||||
Time.runTask(3f, ui.loadfrag::hide);
|
||||
|
||||
ui.showError("$disconnect");
|
||||
if(packet.reason != null){
|
||||
if(packet.reason.equals("closed")){
|
||||
ui.showSmall("$disconnect", "$disconnect.closed");
|
||||
}else if(packet.reason.equals("timeout")){
|
||||
ui.showSmall("$disconnect", "$disconnect.timeout");
|
||||
}else if(packet.reason.equals("error")){
|
||||
ui.showSmall("$disconnect", "$disconnect.error");
|
||||
}
|
||||
}else{
|
||||
ui.showError("$disconnect");
|
||||
}
|
||||
});
|
||||
|
||||
Net.handleClient(WorldStream.class, data -> {
|
||||
|
||||
@@ -76,7 +76,7 @@ public class NetServer implements ApplicationListener{
|
||||
Net.handleServer(Disconnect.class, (id, packet) -> {
|
||||
Player player = connections.get(id);
|
||||
if(player != null){
|
||||
onDisconnect(player);
|
||||
onDisconnect(player, packet.reason);
|
||||
}
|
||||
connections.remove(id);
|
||||
});
|
||||
@@ -362,7 +362,7 @@ public class NetServer implements ApplicationListener{
|
||||
Log.debug("Packed {0} compressed bytes of world data.", stream.size());
|
||||
}
|
||||
|
||||
public static void onDisconnect(Player player){
|
||||
public static void onDisconnect(Player player, String reason){
|
||||
//singleplayer multiplayer wierdness
|
||||
if(player.con == null){
|
||||
player.remove();
|
||||
@@ -375,7 +375,7 @@ public class NetServer implements ApplicationListener{
|
||||
}
|
||||
player.remove();
|
||||
netServer.connections.remove(player.con.id);
|
||||
Log.info("&lm[{1}] &lc{0} has disconnected.", player.name, player.uuid);
|
||||
Log.info("&lm[{1}] &lc{0} has disconnected. &lg&fi({2})", player.name, player.uuid, reason);
|
||||
}
|
||||
|
||||
private static float compound(float speed, float drag){
|
||||
@@ -701,7 +701,7 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
if(connection == null || !connection.isConnected() || !connections.containsKey(connection.id)){
|
||||
//player disconnected, call d/c event
|
||||
onDisconnect(player);
|
||||
onDisconnect(player, "disappeared");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -360,6 +360,15 @@ public class UI implements ApplicationListener, Loadable{
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showSmall(String titleText, String text){
|
||||
new Dialog(titleText, "dialog"){{
|
||||
cont.margin(10).add(text);
|
||||
titleTable.row();
|
||||
titleTable.addImage("whiteui").color(Pal.accent).height(3f).growX().pad(2f);
|
||||
buttons.addButton("$ok", this::hide).size(90, 50).pad(4);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showConfirm(String title, String text, Runnable confirmed){
|
||||
showConfirm(title, text, null, confirmed);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public class Packets{
|
||||
|
||||
public static class Disconnect implements Packet{
|
||||
public int id;
|
||||
public String reason;
|
||||
|
||||
@Override
|
||||
public boolean isImportant(){
|
||||
|
||||
Reference in New Issue
Block a user