Merge branch 'cbt-multi-controller' into css
# Conflicts: # racevisionGame/src/main/java/mock/app/App.java # racevisionGame/src/main/java/visualiser/Controllers/ConnectionController.java # racevisionGame/src/main/java/visualiser/app/App.java # racevisionGame/src/main/java/visualiser/model/RaceConnection.java # racevisionGame/src/main/resources/visualiser/scenes/connect.fxml
This commit is contained in:
@@ -5,12 +5,18 @@ import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import mock.app.Event;
|
||||
import shared.exceptions.InvalidBoatDataException;
|
||||
import shared.exceptions.InvalidRaceDataException;
|
||||
import shared.exceptions.InvalidRegattaDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
import visualiser.model.RaceConnection;
|
||||
|
||||
import javax.xml.soap.Text;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
@@ -79,8 +85,6 @@ public class ConnectionController extends Controller {
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
// TODO - replace with config file
|
||||
connections = FXCollections.observableArrayList();
|
||||
connections.add(new RaceConnection("livedata.americascup.com", 4941, null));
|
||||
connections.add(new RaceConnection("localhost", 4942, null));
|
||||
|
||||
connectionTable.setItems(connections);
|
||||
hostnameColumn.setCellValueFactory(cellData -> cellData.getValue().hostnameProperty());
|
||||
@@ -113,6 +117,7 @@ public class ConnectionController extends Controller {
|
||||
try{
|
||||
RaceConnection connection = connectionTable.getSelectionModel().getSelectedItem();
|
||||
Socket socket = new Socket(connection.getHostname(), connection.getPort());
|
||||
socket.setKeepAlive(true);
|
||||
connectionWrapper.setVisible(false);
|
||||
parent.enterLobby(socket);
|
||||
} catch (IOException e) { /* Never reached */ }
|
||||
@@ -130,6 +135,29 @@ public class ConnectionController extends Controller {
|
||||
}catch(NumberFormatException e){
|
||||
System.err.println("Port number entered is not a number");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up a new host
|
||||
*/
|
||||
public void addLocal() {
|
||||
try {
|
||||
Event game = Event.getEvent();
|
||||
urlField.textProperty().set(game.getAddress());
|
||||
portField.textProperty().set(Integer.toString(game.getPort()));
|
||||
|
||||
game.start();
|
||||
addConnection();
|
||||
} catch (InvalidRaceDataException e) {
|
||||
e.printStackTrace();
|
||||
} catch (XMLReaderException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidBoatDataException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidRegattaDataException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user