Check method moved to new class called ping so that refresh will be called on new thread.
#story[1087]
This commit is contained in:
@@ -35,21 +35,9 @@ public class RaceConnection {
|
||||
* @return true if socket can connect
|
||||
*/
|
||||
public boolean check() {
|
||||
//TODO the connection needs to be moved to its own thread, so it doesn't block fx thread.
|
||||
InetSocketAddress i = new InetSocketAddress(hostname.get(), port);
|
||||
try (Socket s = new Socket()){
|
||||
s.connect(i, 750);//TODO this should be at least a second or two, once moved to its own thread
|
||||
status.set("Ready");
|
||||
s.shutdownInput();
|
||||
s.shutdownOutput();
|
||||
s.close();
|
||||
//System.out.println(String.valueOf(s.isClosed()));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
status.set("Offline");
|
||||
return false;
|
||||
Ping ping = new Ping(hostname.get(), port, this);
|
||||
new Thread(ping).start();
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getHostname() {
|
||||
|
||||
Reference in New Issue
Block a user