JoinStatus joinStatus = networkSystem.join(address, port);
return joinStatus;
}
};
final NUIManager manager = CoreRegistry.get(NUIManager.class);
final WaitPopup<JoinStatus> popup = manager.pushScreen(WaitPopup.ASSET_URI, WaitPopup.class);
popup.setMessage("Join Game", "Connecting to '" + address + ":" + port + "' - please wait ...");
popup.onSuccess(new Function<JoinStatus, Void>() {
@Override
public Void apply(JoinStatus result) {
GameEngine engine = CoreRegistry.get(GameEngine.class);
if (result.getStatus() != JoinStatus.Status.FAILED) {
engine.changeState(new StateLoading(result));
} else {
MessagePopup screen = manager.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
screen.setMessage("Failed to Join", "Could not connect to server - " + result.getErrorMessage());
}
return null;
}