|
|
|
|
@ -53,6 +53,8 @@ public class VisualiserInput implements Runnable
|
|
|
|
|
|
|
|
|
|
private BufferedInputStream inStream;
|
|
|
|
|
|
|
|
|
|
private boolean receiverLoop = true;
|
|
|
|
|
|
|
|
|
|
public VisualiserInput(Socket socket, StreamedCourse course) throws IOException{
|
|
|
|
|
|
|
|
|
|
this.connectionSocket = socket;
|
|
|
|
|
@ -63,7 +65,6 @@ public class VisualiserInput implements Runnable
|
|
|
|
|
this.boatStatus = new HashMap<>();
|
|
|
|
|
this.markRounding = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//start Time
|
|
|
|
|
this.lastHeartbeatTime = System.currentTimeMillis();
|
|
|
|
|
}
|
|
|
|
|
@ -169,10 +170,16 @@ public class VisualiserInput implements Runnable
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void run(){
|
|
|
|
|
this.receiverLoop = true;
|
|
|
|
|
try{
|
|
|
|
|
//receiver loop that gets the input
|
|
|
|
|
boolean receiverLoop = true;
|
|
|
|
|
while(receiverLoop) {
|
|
|
|
|
//if no heartbeat has been received in more than 6 seconds
|
|
|
|
|
//the connection will need to be restarted
|
|
|
|
|
if (timeSinceHeartbeat() > 6){
|
|
|
|
|
System.out.println("Connection has stopped, trying to reconnect");
|
|
|
|
|
receiverLoop = false;
|
|
|
|
|
}
|
|
|
|
|
//converts the input into a byte array that can be read by the decoder
|
|
|
|
|
byte[] binaryMessage = getBytes();
|
|
|
|
|
//if there is no bytes read.
|
|
|
|
|
@ -279,19 +286,16 @@ public class VisualiserInput implements Runnable
|
|
|
|
|
System.out.println("Broken Message!");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if no heartbeat has been received in more than 6 seconds
|
|
|
|
|
//the connection will need to be restarted
|
|
|
|
|
if (timeSinceHeartbeat() > 6){
|
|
|
|
|
System.out.println("Connection has stopped, trying to reconnect");
|
|
|
|
|
receiverLoop = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch(IOException e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isReceiverLoop() {
|
|
|
|
|
return receiverLoop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String argv[]) throws Exception
|
|
|
|
|
{
|
|
|
|
|
Socket socket = new Socket("livedata.americascup.com", 4941);
|
|
|
|
|
|