mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merge branch '1047_Hosting_Game' into Story62_Reading_Keystrokes
# Conflicts: # src/main/resources/views/RaceView.fxml
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user