diff --git a/network/src/main/java/seng302/Networking/VisualiserInput.java b/network/src/main/java/seng302/Networking/VisualiserInput.java index b7896655..c0040cb3 100644 --- a/network/src/main/java/seng302/Networking/VisualiserInput.java +++ b/network/src/main/java/seng302/Networking/VisualiserInput.java @@ -32,7 +32,8 @@ public class VisualiserInput implements Runnable public VisualiserInput(Socket connectionSocket) throws IOException{ - connectionSocket = new Socket(InetAddress.getLocalHost(), 4942); + //connectionSocket = new Socket(InetAddress.getLocalHost(), 4942); + this.connectionSocket = connectionSocket; this.course = new StreamedCourse(); this.boatLocation = new HashMap<>(); @@ -79,11 +80,14 @@ public class VisualiserInput implements Runnable */ private static byte[] getBytes(InputStream inStream) throws IOException { byte[] headerBytes = new byte[15]; - int i = inStream.read(headerBytes); + inStream.read(headerBytes); byte[] messageLenBytes = Arrays.copyOfRange(headerBytes, 13, 15); short messageLen = bytesToShort(messageLenBytes); byte[] messageBytesWithCRC = new byte[messageLen+4]; - int j = inStream.read(messageBytesWithCRC); + while (inStream.available() < messageLen + 4){ + //WE NEED THIS!!!! + } + inStream.read(messageBytesWithCRC, 0, messageLen + 4); ByteBuffer binaryMessageBytes = ByteBuffer.allocate(headerBytes.length+messageBytesWithCRC.length); binaryMessageBytes.put(headerBytes); binaryMessageBytes.put(messageBytesWithCRC);