Merge branch 'splitIntoTwoModules' of https://eng-git.canterbury.ac.nz/seng302-2017/team-7 into splitIntoTwoModules
This commit is contained in:
@@ -32,7 +32,8 @@ public class VisualiserInput implements Runnable
|
|||||||
|
|
||||||
public VisualiserInput(Socket connectionSocket) throws IOException{
|
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.course = new StreamedCourse();
|
||||||
this.boatLocation = new HashMap<>();
|
this.boatLocation = new HashMap<>();
|
||||||
@@ -79,11 +80,14 @@ public class VisualiserInput implements Runnable
|
|||||||
*/
|
*/
|
||||||
private static byte[] getBytes(InputStream inStream) throws IOException {
|
private static byte[] getBytes(InputStream inStream) throws IOException {
|
||||||
byte[] headerBytes = new byte[15];
|
byte[] headerBytes = new byte[15];
|
||||||
int i = inStream.read(headerBytes);
|
inStream.read(headerBytes);
|
||||||
byte[] messageLenBytes = Arrays.copyOfRange(headerBytes, 13, 15);
|
byte[] messageLenBytes = Arrays.copyOfRange(headerBytes, 13, 15);
|
||||||
short messageLen = bytesToShort(messageLenBytes);
|
short messageLen = bytesToShort(messageLenBytes);
|
||||||
byte[] messageBytesWithCRC = new byte[messageLen+4];
|
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);
|
ByteBuffer binaryMessageBytes = ByteBuffer.allocate(headerBytes.length+messageBytesWithCRC.length);
|
||||||
binaryMessageBytes.put(headerBytes);
|
binaryMessageBytes.put(headerBytes);
|
||||||
binaryMessageBytes.put(messageBytesWithCRC);
|
binaryMessageBytes.put(messageBytesWithCRC);
|
||||||
|
|||||||
Reference in New Issue
Block a user