Disabled multiplayer for HTML5, net bugfixes

This commit is contained in:
Anuken
2018-01-19 18:27:41 -05:00
parent 1dad6b27c7
commit b1a38c3e61
11 changed files with 209 additions and 250 deletions

View File

@@ -62,40 +62,33 @@ public class KryoClient implements ClientProvider{
c.id = connection.getID();
if(connection.getRemoteAddressTCP() != null) c.addressTCP = connection.getRemoteAddressTCP().toString();
try{
Net.handleClientReceived(c);
}catch (Exception e){
Gdx.app.postRunnable(() -> {throw new RuntimeException(e);});
}
Gdx.app.postRunnable(() -> Net.handleClientReceived(c));
}
@Override
public void disconnected (Connection connection) {
Disconnect c = new Disconnect();
try{
Net.handleClientReceived(c);
}catch (Exception e){
Gdx.app.postRunnable(() -> {throw new RuntimeException(e);});
}
Gdx.app.postRunnable(() -> Net.handleClientReceived(c));
}
@Override
public void received (Connection connection, Object object) {
if(object instanceof FrameworkMessage) return;
try{
Net.handleClientReceived(object);
}catch (Exception e){
if(e instanceof KryoNetException && e.getMessage() != null && e.getMessage().toLowerCase().contains("incorrect")) {
Gdx.app.postRunnable(() -> Vars.ui.showError("$text.server.mismatch"));
Vars.netClient.disconnectQuietly();
}else{
Gdx.app.postRunnable(() -> {
Gdx.app.postRunnable(() -> {
try{
Net.handleClientReceived(object);
}catch (Exception e){
if(e instanceof KryoNetException && e.getMessage() != null && e.getMessage().toLowerCase().contains("incorrect")) {
Vars.ui.showError("$text.server.mismatch");
Vars.netClient.disconnectQuietly();
}else{
throw new RuntimeException(e);
});
}
}
}
});
}
};

View File

@@ -66,12 +66,8 @@ public class KryoServer implements ServerProvider {
c.id = kn.id;
c.addressTCP = connection.getRemoteAddressTCP().toString();
try {
Net.handleServerReceived(c, kn.id);
connections.add(kn);
}catch (Exception e){
Gdx.app.postRunnable(() -> {throw new RuntimeException(e);});
}
connections.add(kn);
Gdx.app.postRunnable(() -> Net.handleServerReceived(c, kn.id));
}
@Override
@@ -83,11 +79,7 @@ public class KryoServer implements ServerProvider {
Disconnect c = new Disconnect();
c.id = k.id;
try{
Net.handleServerReceived(c, c.id);
}catch (Exception e){
Gdx.app.postRunnable(() -> {throw new RuntimeException(e);});
}
Gdx.app.postRunnable(() -> Net.handleServerReceived(c, c.id));
}
@Override
@@ -95,11 +87,13 @@ public class KryoServer implements ServerProvider {
KryoConnection k = getByKryoID(connection.getID());
if(object instanceof FrameworkMessage || k == null) return;
try{
Net.handleServerReceived(object, k.id);
}catch (Exception e){
e.printStackTrace();
}
Gdx.app.postRunnable(() -> {
try{
Net.handleServerReceived(object, k.id);
}catch (Exception e){
e.printStackTrace();
}
});
}
};