mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
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:
@@ -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.zip.CRC32;
|
||||
|
||||
public class XMLMessage extends Message{
|
||||
@@ -45,7 +48,7 @@ public class XMLMessage extends Message{
|
||||
* Send this message as a stream of bytes
|
||||
* @param outputStream The output stream to send the message
|
||||
*/
|
||||
public void send(DataOutputStream outputStream) {
|
||||
public void send(SocketChannel outputStream) throws IOException {
|
||||
allocateBuffer();
|
||||
writeHeaderToBuffer();
|
||||
|
||||
@@ -60,11 +63,6 @@ public class XMLMessage extends Message{
|
||||
|
||||
writeCRC();
|
||||
|
||||
// Send
|
||||
try {
|
||||
outputStream.write(getBuffer().array());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
outputStream.write(getBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user