mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-13 12:16:53 +07:00
Stability improvements, minor fixes. Ready to merge.
This commit is contained in:
parent
65d472cac7
commit
6aefc22ac9
@ -46,6 +46,7 @@ text.connecting=[accent]Connecting...
|
|||||||
text.connecting.data=[accent]Loading world data...
|
text.connecting.data=[accent]Loading world data...
|
||||||
text.connectfail=[crimson]Failed to connect to server: [orange]{0}
|
text.connectfail=[crimson]Failed to connect to server: [orange]{0}
|
||||||
text.server.port=Port:
|
text.server.port=Port:
|
||||||
|
text.server.addressinuse=Address already in use!
|
||||||
text.server.invalidport=Invalid port number!
|
text.server.invalidport=Invalid port number!
|
||||||
text.server.error=[crimson]Error hosting server: [orange]{0}
|
text.server.error=[crimson]Error hosting server: [orange]{0}
|
||||||
text.tutorial.back=< Prev
|
text.tutorial.back=< Prev
|
||||||
|
@ -32,7 +32,7 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
addCloseButton();
|
addCloseButton();
|
||||||
|
|
||||||
join = new FloatingDialog("$text.joingame.title");
|
join = new FloatingDialog("$text.joingame.title");
|
||||||
join.content().add("$text.joingame.ip").left();
|
join.content().add("$text.joingame.ip").padRight(5f).left();
|
||||||
Mindustry.platforms.addDialog(join.content().addField(Settings.getString("ip"),text ->{
|
Mindustry.platforms.addDialog(join.content().addField(Settings.getString("ip"),text ->{
|
||||||
Settings.putString("ip", text);
|
Settings.putString("ip", text);
|
||||||
Settings.save();
|
Settings.save();
|
||||||
|
@ -29,6 +29,7 @@ import org.java_websocket.handshake.ClientHandshake;
|
|||||||
import org.java_websocket.server.WebSocketServer;
|
import org.java_websocket.server.WebSocketServer;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.BindException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -156,7 +157,7 @@ public class KryoServer implements ServerProvider {
|
|||||||
Thread thread = new Thread(() ->{
|
Thread thread = new Thread(() ->{
|
||||||
try {
|
try {
|
||||||
server.close();
|
server.close();
|
||||||
webServer.stop(1); //please die, right now
|
if(webServer != null) webServer.stop(1); //please die, right now
|
||||||
//kill them all
|
//kill them all
|
||||||
for(Thread worker : Thread.getAllStackTraces().keySet()){
|
for(Thread worker : Thread.getAllStackTraces().keySet()){
|
||||||
if(worker.getName().contains("WebSocketWorker")){
|
if(worker.getName().contains("WebSocketWorker")){
|
||||||
@ -255,7 +256,7 @@ public class KryoServer implements ServerProvider {
|
|||||||
public void dispose(){
|
public void dispose(){
|
||||||
try {
|
try {
|
||||||
server.dispose();
|
server.dispose();
|
||||||
webServer.stop(1);
|
if(webServer != null) webServer.stop(1);
|
||||||
//kill them all
|
//kill them all
|
||||||
for(Thread thread : Thread.getAllStackTraces().keySet()){
|
for(Thread thread : Thread.getAllStackTraces().keySet()){
|
||||||
if(thread.getName().contains("WebSocketWorker")){
|
if(thread.getName().contains("WebSocketWorker")){
|
||||||
@ -378,20 +379,24 @@ public class KryoServer implements ServerProvider {
|
|||||||
@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;
|
||||||
Disconnect disconnect = new Disconnect();
|
|
||||||
KryoConnection k = getBySocket(conn);
|
KryoConnection k = getBySocket(conn);
|
||||||
if(k != null) Net.handleServerReceived(disconnect, k.id);
|
if(k == null) return;
|
||||||
|
Disconnect disconnect = new Disconnect();
|
||||||
|
disconnect.id = k.id;
|
||||||
|
Net.handleServerReceived(disconnect, k.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(WebSocket conn, String message) {
|
public void onMessage(WebSocket conn, String message) {
|
||||||
try {
|
try {
|
||||||
|
KryoConnection k = getBySocket(conn);
|
||||||
|
if (k == null) return;
|
||||||
|
|
||||||
if(message.equals("_ping_")){
|
if(message.equals("_ping_")){
|
||||||
conn.send(connections.size() + "|" + Vars.player.name);
|
conn.send(connections.size() + "|" + Vars.player.name);
|
||||||
|
connections.remove(k);
|
||||||
}else {
|
}else {
|
||||||
if (debug) UCore.log("Got message: " + message);
|
if (debug) UCore.log("Got message: " + message);
|
||||||
KryoConnection k = getBySocket(conn);
|
|
||||||
if (k == null) return;
|
|
||||||
|
|
||||||
byte[] out = Base64Coder.decode(message);
|
byte[] out = Base64Coder.decode(message);
|
||||||
if (debug) UCore.log("Decoded: " + Arrays.toString(out));
|
if (debug) UCore.log("Decoded: " + Arrays.toString(out));
|
||||||
@ -409,6 +414,10 @@ public class KryoServer implements ServerProvider {
|
|||||||
public void onError(WebSocket conn, Exception ex) {
|
public void onError(WebSocket conn, Exception ex) {
|
||||||
UCore.log("WS error:");
|
UCore.log("WS error:");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
if(ex instanceof BindException){
|
||||||
|
Net.closeServer();
|
||||||
|
Vars.ui.showError("$text.server.addressinuse");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user