WIP. Probably need to cherry pick stuff out of here.
Added ClientConnection and server-side handshake. Added MessageSerialiser and Deserialiser. #story[1095]
This commit is contained in:
@@ -20,6 +20,7 @@ import shared.exceptions.InvalidRegattaDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
import visualiser.app.VisualiserInput;
|
||||
import visualiser.gameController.ControllerClient;
|
||||
import visualiser.model.ServerConnection;
|
||||
import visualiser.model.VisualiserBoat;
|
||||
import visualiser.model.VisualiserRace;
|
||||
|
||||
@@ -27,6 +28,8 @@ import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Controller to for waiting for the race to start.
|
||||
@@ -66,18 +69,18 @@ public class StartController extends Controller implements Observer {
|
||||
@FXML private Label raceStatusLabel;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The object used to read packets from the connected server.
|
||||
* Our connection to the server.
|
||||
*/
|
||||
private VisualiserInput visualiserInput;
|
||||
private ServerConnection serverConnection;
|
||||
|
||||
|
||||
/**
|
||||
* The race object which describes the currently occurring race.
|
||||
*/
|
||||
private VisualiserRace visualiserRace;
|
||||
|
||||
private ControllerClient controllerClient;
|
||||
|
||||
|
||||
/**
|
||||
* An array of colors used to assign colors to each boat - passed in to the VisualiserRace constructor.
|
||||
@@ -309,17 +312,17 @@ public class StartController extends Controller implements Observer {
|
||||
public void enterLobby(Socket socket) {
|
||||
startWrapper.setVisible(true);
|
||||
try {
|
||||
//Begin reading packets from the socket/server.
|
||||
this.visualiserInput = new VisualiserInput(socket);
|
||||
//Send controller input to server
|
||||
this.controllerClient = new ControllerClient(socket);
|
||||
|
||||
LatestMessages latestMessages = new LatestMessages();
|
||||
this.serverConnection = new ServerConnection(socket, latestMessages);
|
||||
|
||||
|
||||
//Store a reference to latestMessages so that we can observe it.
|
||||
LatestMessages latestMessages = this.visualiserInput.getLatestMessages();
|
||||
latestMessages.addObserver(this);
|
||||
new Thread(this.visualiserInput).start();
|
||||
new Thread(this.serverConnection).start();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Logger.getGlobal().log(Level.WARNING, "Could not connection to server.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user