Merge branch '1047_Hosting_Game' into Story62_Reading_Keystrokes

# Conflicts:
#	src/main/resources/views/RaceView.fxml
This commit is contained in:
Zhi You Tan
2017-07-14 16:28:42 +12:00
25 changed files with 1390 additions and 353 deletions
@@ -43,10 +43,21 @@ public class Header {
buff.position(buffPos);
}
/**
* Reset the buffer
*/
public void reset(){
buffPos = 0;
buff.clear();
buff.position(buffPos);
}
/**
* @return a ByteBuffer containing the message header
*/
public ByteBuffer getByteBuffer(){
reset();
putInBuffer(ByteBuffer.allocate(1).put((byte)syncByte1).array(), syncByte1);
putInBuffer(ByteBuffer.allocate(1).put((byte)syncByte2).array(), syncByte2);
@@ -45,6 +45,7 @@ public abstract class Message {
buffer = ByteBuffer.allocate(Header.getSize() + getSize() + CRC_SIZE);
buffer.order(ByteOrder.LITTLE_ENDIAN);
bufferPosition = 0;
buffer.position(bufferPosition);
}
/**
@@ -54,6 +54,15 @@ public class RaceStartStatusMessage extends Message {
writeCRC();
rewind();
outputStream.write(getBuffer());
if (outputStream == null){
return;
}
try{
outputStream.write(getBuffer());
}
catch (IOException e){
return;
}
}
}