Added connection screen to allow users to select available hosts from a preconfigured list.

- Added ConnectionController for initial client setup
- Added RaceConnection class for socket data and checking
- Configures StartController with a socket drawn from a host table

#story[782]
This commit is contained in:
Connor Taylor-Brown
2017-05-03 03:40:36 +12:00
parent ad58407021
commit ac4fbda848
9 changed files with 236 additions and 111 deletions
@@ -1,14 +1,53 @@
package seng302;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import java.io.IOException;
import java.net.Socket;
/**
* Created by cbt24 on 3/05/17.
*/
public class RaceConnection {
private String hostname;
private StringProperty hostname;
private int port;
private StringProperty status;
public RaceConnection(String hostname, int port) {
this.hostname = hostname;
this.hostname = new SimpleStringProperty(hostname);
this.port = port;
this.status = new SimpleStringProperty("");
check();
}
/**
* Tries to create a socket to hostname and port, indicates status after test.
*/
@SuppressWarnings("unused")
public boolean check() {
try(Socket s = new Socket(hostname.get(), port)) {
status.set("Ready");
return true;
} catch (IOException e) {}
status.set("Offline");
return false;
}
public String getHostname() {
return hostname.get();
}
public StringProperty hostnameProperty() {
return hostname;
}
public int getPort() {
return port;
}
public StringProperty statusProperty() {
return status;
}
}