|
|
|
|
@ -11,10 +11,6 @@ import seng302.Exceptions.InvalidRegattaDataException;
|
|
|
|
|
import seng302.Mock.RaceDataSource;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by esa46 on 21/04/17.
|
|
|
|
|
*/
|
|
|
|
|
@ -22,13 +18,10 @@ public class Event {
|
|
|
|
|
|
|
|
|
|
RaceDataSource raceDataSource;
|
|
|
|
|
RegattaDataSource regattaDataSource;
|
|
|
|
|
///The stream to which we send all data.
|
|
|
|
|
private OutputStream outputStream;
|
|
|
|
|
|
|
|
|
|
public Event(RaceDataSource raceData, RegattaDataSource regattaData, OutputStream outputStream) {
|
|
|
|
|
public Event(RaceDataSource raceData, RegattaDataSource regattaData) {
|
|
|
|
|
this.raceDataSource = raceData;
|
|
|
|
|
this.regattaDataSource = regattaData;
|
|
|
|
|
this.outputStream = outputStream;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void start()
|
|
|
|
|
@ -42,7 +35,7 @@ public class Event {
|
|
|
|
|
|
|
|
|
|
System.out.println("RACE STARTING!!\n\n");//TEMP REMOVE debug
|
|
|
|
|
|
|
|
|
|
Race newRace = new Race(raceDataSource, 15, this.outputStream);
|
|
|
|
|
Race newRace = new Race(raceDataSource, 15);
|
|
|
|
|
new Thread((newRace)).start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -52,19 +45,7 @@ public class Event {
|
|
|
|
|
RegattaData regattaData = new RegattaData(regattaDataSource);
|
|
|
|
|
String xmlString = regattaData.createXML();
|
|
|
|
|
|
|
|
|
|
//TODO now we should place in XML message object.
|
|
|
|
|
//TODO now we should serialize xml message object.
|
|
|
|
|
//TODO now we should write serialized xml message over this.outputStream.
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.outputStream.write(xmlString.toString().getBytes());//TEMP currently we output the XML doc, not the serialized message.
|
|
|
|
|
}
|
|
|
|
|
catch (IOException e)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidRegattaDataException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println(xmlString); // to be replaced by TCPClient.send(xmlString) type function call
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -74,18 +55,7 @@ public class Event {
|
|
|
|
|
//Serialize race data to an XML as a string.
|
|
|
|
|
String xmlString = raceData.createXML();
|
|
|
|
|
|
|
|
|
|
//TODO now we should place in XML message object.
|
|
|
|
|
//TODO now we should serialize xml message object.
|
|
|
|
|
//TODO now we should write serialized xml message over this.outputStream.
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.outputStream.write(xmlString.getBytes());//TEMP currently we output the XML doc, not the serialized message.
|
|
|
|
|
}
|
|
|
|
|
catch (IOException e)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidRaceDataException();
|
|
|
|
|
}
|
|
|
|
|
System.out.println(xmlString); // to be replaced by TCPClient.send(xmlString) type function call
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void sendBoatData() throws InvalidBoatDataException
|
|
|
|
|
@ -94,19 +64,7 @@ public class Event {
|
|
|
|
|
//Serialize race data to an XML as a string.
|
|
|
|
|
String xmlString = boatData.createXML();
|
|
|
|
|
|
|
|
|
|
//TODO now we should place in XML message object.
|
|
|
|
|
//TODO now we should serialize xml message object.
|
|
|
|
|
//TODO now we should write serialized xml message over this.outputStream.
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.outputStream.write(xmlString.getBytes());//TEMP currently we output the XML doc, not the serialized message.
|
|
|
|
|
}
|
|
|
|
|
catch (IOException e)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidBoatDataException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println(xmlString); // to be replaced by TCPClient.send(xmlString) type function call
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|