Fixed stream from messing up
- Stream was getting code before all of it came therefore a while loop was added t owait for the code #story[782] #pair[hba56, fwy13]
This commit is contained in:
@@ -39,7 +39,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<>();
|
||||
@@ -86,11 +87,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);
|
||||
|
||||
Reference in New Issue
Block a user