mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Test NET_CONN no longer should slowdown the main thread
This commit is contained in:
@@ -50,7 +50,7 @@ public final class Constant {
|
|||||||
|
|
||||||
public static class Runtime {
|
public static class Runtime {
|
||||||
/** The Constant NetConn. */
|
/** The Constant NetConn. */
|
||||||
public static boolean NET_CONN = false;
|
public static volatile boolean NET_CONN = false;
|
||||||
|
|
||||||
/** The Constant width. */
|
/** The Constant width. */
|
||||||
public static final int WIDTH = 300;
|
public static final int WIDTH = 300;
|
||||||
|
|||||||
@@ -145,15 +145,30 @@ public enum FModel {
|
|||||||
AllZone.setInputControl(new InputControl(FModel.this));
|
AllZone.setInputControl(new InputControl(FModel.this));
|
||||||
AllZone.getInputControl().setComputer(new ComputerAIInput(new ComputerAIGeneral()));
|
AllZone.getInputControl().setComputer(new ComputerAIInput(new ComputerAIGeneral()));
|
||||||
|
|
||||||
// Set gameplay preferences and constants
|
testNetworkConnection();
|
||||||
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);
|
|
||||||
|
|
||||||
this.setBuildInfo(new BuildInfo());
|
this.setBuildInfo(new BuildInfo());
|
||||||
FModel.loadDynamicGamedata();
|
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.
|
* Load dynamic gamedata.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user