Slightly more informative D/C messages
This commit is contained in:
@@ -118,6 +118,9 @@ confirmunadmin = Are you sure you want to remove admin status from this player?
|
|||||||
joingame.title = Join Game
|
joingame.title = Join Game
|
||||||
joingame.ip = Address:
|
joingame.ip = Address:
|
||||||
disconnect = Disconnected.
|
disconnect = Disconnected.
|
||||||
|
disconnect.error = Connection error.
|
||||||
|
disconnect.closed = Connection closed.
|
||||||
|
disconnect.timeout = Timed out.
|
||||||
disconnect.data = Failed to load world data!
|
disconnect.data = Failed to load world data!
|
||||||
connecting = [accent]Connecting...
|
connecting = [accent]Connecting...
|
||||||
connecting.data = [accent]Loading world data...
|
connecting.data = [accent]Loading world data...
|
||||||
|
|||||||
@@ -107,7 +107,17 @@ public class NetClient implements ApplicationListener{
|
|||||||
|
|
||||||
Time.runTask(3f, ui.loadfrag::hide);
|
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 -> {
|
Net.handleClient(WorldStream.class, data -> {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
Net.handleServer(Disconnect.class, (id, packet) -> {
|
Net.handleServer(Disconnect.class, (id, packet) -> {
|
||||||
Player player = connections.get(id);
|
Player player = connections.get(id);
|
||||||
if(player != null){
|
if(player != null){
|
||||||
onDisconnect(player);
|
onDisconnect(player, packet.reason);
|
||||||
}
|
}
|
||||||
connections.remove(id);
|
connections.remove(id);
|
||||||
});
|
});
|
||||||
@@ -362,7 +362,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
Log.debug("Packed {0} compressed bytes of world data.", stream.size());
|
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
|
//singleplayer multiplayer wierdness
|
||||||
if(player.con == null){
|
if(player.con == null){
|
||||||
player.remove();
|
player.remove();
|
||||||
@@ -375,7 +375,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
player.remove();
|
player.remove();
|
||||||
netServer.connections.remove(player.con.id);
|
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){
|
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)){
|
if(connection == null || !connection.isConnected() || !connections.containsKey(connection.id)){
|
||||||
//player disconnected, call d/c event
|
//player disconnected, call d/c event
|
||||||
onDisconnect(player);
|
onDisconnect(player, "disappeared");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -360,6 +360,15 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
}}.show();
|
}}.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){
|
public void showConfirm(String title, String text, Runnable confirmed){
|
||||||
showConfirm(title, text, null, confirmed);
|
showConfirm(title, text, null, confirmed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class Packets{
|
|||||||
|
|
||||||
public static class Disconnect implements Packet{
|
public static class Disconnect implements Packet{
|
||||||
public int id;
|
public int id;
|
||||||
|
public String reason;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isImportant(){
|
public boolean isImportant(){
|
||||||
|
|||||||
@@ -36,12 +36,13 @@ public class ArcNetClient implements ClientProvider{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected(Connection connection){
|
public void disconnected(Connection connection, DcReason reason){
|
||||||
if(connection.getLastProtocolError() != null){
|
if(connection.getLastProtocolError() != null){
|
||||||
netClient.setQuiet();
|
netClient.setQuiet();
|
||||||
}
|
}
|
||||||
|
|
||||||
Disconnect c = new Disconnect();
|
Disconnect c = new Disconnect();
|
||||||
|
c.reason = reason.toString();
|
||||||
Core.app.post(() -> Net.handleClientReceived(c));
|
Core.app.post(() -> Net.handleClientReceived(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,12 +47,13 @@ public class ArcNetServer implements ServerProvider{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected(Connection connection){
|
public void disconnected(Connection connection, DcReason reason){
|
||||||
ArcConnection k = getByKryoID(connection.getID());
|
ArcConnection k = getByKryoID(connection.getID());
|
||||||
if(k == null) return;
|
if(k == null) return;
|
||||||
|
|
||||||
Disconnect c = new Disconnect();
|
Disconnect c = new Disconnect();
|
||||||
c.id = k.id;
|
c.id = k.id;
|
||||||
|
c.reason = reason.toString();
|
||||||
|
|
||||||
Core.app.post(() -> {
|
Core.app.post(() -> {
|
||||||
Net.handleServerReceived(k.id, c);
|
Net.handleServerReceived(k.id, c);
|
||||||
@@ -159,7 +160,7 @@ public class ArcNetServer implements ServerProvider{
|
|||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
Log.err(e);
|
Log.err(e);
|
||||||
Log.info("Error sending packet. Disconnecting invalid client!");
|
Log.info("Error sending packet. Disconnecting invalid client!");
|
||||||
connection.close();
|
connection.close(DcReason.error);
|
||||||
|
|
||||||
ArcConnection k = getByKryoID(connection.getID());
|
ArcConnection k = getByKryoID(connection.getID());
|
||||||
if(k != null) connections.remove(k);
|
if(k != null) connections.remove(k);
|
||||||
@@ -168,7 +169,7 @@ public class ArcNetServer implements ServerProvider{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close(){
|
public void close(){
|
||||||
if(connection.isConnected()) connection.close();
|
if(connection.isConnected()) connection.close(DcReason.closed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user