mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
e83eaa38e1
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]
33 lines
850 B
Java
33 lines
850 B
Java
package seng302.server.messages;
|
|
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.nio.ByteBuffer;
|
|
|
|
/**
|
|
* Created by kre39 on 12/07/17.
|
|
*/
|
|
public class BoatActionMessage extends Message{
|
|
private final MessageType MESSAGE_TYPE = MessageType.BOAT_ACTION;
|
|
private final int MESSAGE_SIZE = 1;
|
|
private BoatActionType actionType;
|
|
|
|
public BoatActionMessage(BoatActionType actionType) {
|
|
this.actionType = actionType;
|
|
setHeader(new Header(MessageType.BOAT_ACTION, 0, (short) 1)); // the second variable is the source id
|
|
allocateBuffer();
|
|
writeHeaderToBuffer();
|
|
// Write message fields
|
|
putInt((int) BoatActionType.getBoatPacketType(actionType), 1);
|
|
writeCRC();
|
|
rewind();
|
|
|
|
}
|
|
|
|
@Override
|
|
public int getSize() {
|
|
return MESSAGE_SIZE;
|
|
}
|
|
|
|
}
|