mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Upon hosting, and then creating a new instance and connecting to that IP, button transmissions work and print out on server!! :D
Took the send method out of the Message class as it didnt make sense to have it there. This meant taking it out of all subclasses too tags: #story[1055] pair[wmu16, zyt10]
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
package seng302.server.messages;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class BoatLocationMessage extends Message {
|
||||
private final int MESSAGE_SIZE = 56;
|
||||
@@ -65,6 +64,36 @@ public class BoatLocationMessage extends Message {
|
||||
this.rudderAngle = 0;
|
||||
|
||||
setHeader(new Header(MessageType.BOAT_LOCATION, 1, (short) getSize()));
|
||||
allocateBuffer();
|
||||
writeHeaderToBuffer();
|
||||
|
||||
long headingToSend = (long)((heading/360.0) * 65535.0);
|
||||
|
||||
putByte((byte) messageVersionNumber);
|
||||
putInt(time, 6);
|
||||
putInt((int) sourceId, 4);
|
||||
putUnsignedInt((int) sequenceNum, 4);
|
||||
putByte((byte) deviceType.getCode());
|
||||
putInt((int) latLonToBinaryPackedLong(latitude), 4);
|
||||
putInt((int) latLonToBinaryPackedLong(longitude), 4);
|
||||
putInt((int) altitude, 4);
|
||||
putInt(headingToSend, 2);
|
||||
putInt((int) pitch, 2);
|
||||
putInt((int) roll, 2);
|
||||
putInt((int) boatSpeed, 2);
|
||||
putUnsignedInt((int) COG, 2);
|
||||
putUnsignedInt((int) SOG, 2);
|
||||
putUnsignedInt((int) apparentWindSpeed, 2);
|
||||
putInt((int) apparentWindAngle, 2);
|
||||
putUnsignedInt((int) trueWindSpeed, 2);
|
||||
putUnsignedInt((int) trueWindDirection, 2);
|
||||
putInt((int) trueWindAngle, 2);
|
||||
putUnsignedInt((int) currentDrift, 2);
|
||||
putUnsignedInt((int) currentSet, 2);
|
||||
putInt((int) rudderAngle, 2);
|
||||
|
||||
writeCRC();
|
||||
rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,41 +154,4 @@ public class BoatLocationMessage extends Message {
|
||||
public int getSize() {
|
||||
return MESSAGE_SIZE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void send(SocketChannel outputStream) throws IOException{
|
||||
allocateBuffer();
|
||||
writeHeaderToBuffer();
|
||||
|
||||
long headingToSend = (long)((heading/360.0) * 65535.0);
|
||||
|
||||
putByte((byte) messageVersionNumber);
|
||||
putInt(time, 6);
|
||||
putInt((int) sourceId, 4);
|
||||
putUnsignedInt((int) sequenceNum, 4);
|
||||
putByte((byte) deviceType.getCode());
|
||||
putInt((int) latLonToBinaryPackedLong(latitude), 4);
|
||||
putInt((int) latLonToBinaryPackedLong(longitude), 4);
|
||||
putInt((int) altitude, 4);
|
||||
putInt(headingToSend, 2);
|
||||
putInt((int) pitch, 2);
|
||||
putInt((int) roll, 2);
|
||||
putInt((int) boatSpeed, 2);
|
||||
putUnsignedInt((int) COG, 2);
|
||||
putUnsignedInt((int) SOG, 2);
|
||||
putUnsignedInt((int) apparentWindSpeed, 2);
|
||||
putInt((int) apparentWindAngle, 2);
|
||||
putUnsignedInt((int) trueWindSpeed, 2);
|
||||
putUnsignedInt((int) trueWindDirection, 2);
|
||||
putInt((int) trueWindAngle, 2);
|
||||
putUnsignedInt((int) currentDrift, 2);
|
||||
putUnsignedInt((int) currentSet, 2);
|
||||
putInt((int) rudderAngle, 2);
|
||||
|
||||
writeCRC();
|
||||
rewind();
|
||||
|
||||
outputStream.write(getBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user