Getting boat locations from race simulator & bug fixes

- Boat locations that are generated by the simulator are sent to the client as they happen
- Fixed heading and lat/lon encoding
- Fixed a bug where the header wasn't included in the sent byte stream
- Fixed the format of data as it's sent to the client.
- Data is now sent using a channel
- Removed tests that don't work with channels

Tags: #story[829]
This commit is contained in:
Michael Rausch
2017-04-29 19:38:21 +12:00
parent 8a04a0e5b7
commit 3e97f016d5
16 changed files with 330 additions and 354 deletions
@@ -3,6 +3,9 @@ package seng302.server.messages;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.SocketChannel;
import java.nio.channels.WritableByteChannel;
import java.util.List;
import java.util.zip.CRC32;
@@ -63,7 +66,7 @@ public class RaceStatusMessage extends Message{
* @param outputStream The output stream to send the message
*/
@Override
public void send(DataOutputStream outputStream) {
public void send(SocketChannel outputStream) throws IOException {
allocateBuffer();
writeHeaderToBuffer();
@@ -83,11 +86,6 @@ public class RaceStatusMessage extends Message{
writeCRC();
// Send
try {
outputStream.write(getBuffer().array());
} catch (IOException e) {
e.printStackTrace();
}
outputStream.write(getBuffer());
}
}