Test NET_CONN no longer should slowdown the main thread

This commit is contained in:
Maxmtg
2012-10-07 09:22:00 +00:00
parent a999982d89
commit 0cbec0e5a9
2 changed files with 21 additions and 6 deletions

View File

@@ -145,15 +145,30 @@ public enum FModel {
AllZone.setInputControl(new InputControl(FModel.this));
AllZone.getInputControl().setComputer(new ComputerAIInput(new ComputerAIGeneral()));
// Set gameplay preferences and constants
final HttpUtil pinger = new HttpUtil();
final String url = ForgeProps.getProperty(NewConstants.CARDFORGE_URL) + "/draftAI/ping.php";
Constant.Runtime.NET_CONN = (pinger.getURL(url).equals("pong") ? true : false);
testNetworkConnection();
this.setBuildInfo(new BuildInfo());
FModel.loadDynamicGamedata();
}
/**
* Tests if draft upload is technically possible.
* Separate thread, no more hangs when network connection is limited
*/
private void testNetworkConnection() {
//
Runnable runNetworkTest = new Runnable() {
@Override
public void run() {
final HttpUtil pinger = new HttpUtil();
final String url = ForgeProps.getProperty(NewConstants.CARDFORGE_URL) + "/draftAI/ping.php";
Constant.Runtime.NET_CONN = pinger.getURL(url).equals("pong");
}
};
Thread testNetConnection = new Thread(runNetworkTest, "CheckRemoteDraftAI");
testNetConnection.start();
}
/**
* Load dynamic gamedata.
*/