Rather than a high frequency loop sending all packets a low frequency loop is made then destroyed on button press for sending turn packets. This means a fast response time on button press but fewer packets sent.

#implement #issue[38]
This commit is contained in:
Calum
2017-08-13 18:38:24 +12:00
parent 30a6cb98ec
commit 2093e79b6a
11 changed files with 95 additions and 78 deletions
@@ -6,7 +6,7 @@ import java.util.Map;
/**
* Created by kre39 on 12/07/17.
*/
public enum BoatActionType {
public enum BoatAction {
VMG(1),
SAILS_IN(2),
@@ -17,19 +17,19 @@ public enum BoatActionType {
MAINTAIN_HEADING(7);
private final int type;
private static final Map<Integer, BoatActionType> intToTypeMap = new HashMap<>();
private static final Map<Integer, BoatAction> intToTypeMap = new HashMap<>();
static {
for (BoatActionType type : BoatActionType.values()) {
for (BoatAction type : BoatAction.values()) {
intToTypeMap.put(type.getValue(), type);
}
}
BoatActionType(int type){
BoatAction(int type){
this.type = type;
}
public static BoatActionType getType(int value) {
public static BoatAction getType(int value) {
return intToTypeMap.get(value);
}
@@ -6,9 +6,9 @@ package seng302.gameServer.server.messages;
public class BoatActionMessage extends Message{
private final MessageType MESSAGE_TYPE = MessageType.BOAT_ACTION;
private final int MESSAGE_SIZE = 1;
private BoatActionType actionType;
private BoatAction actionType;
public BoatActionMessage(BoatActionType actionType) {
public BoatActionMessage(BoatAction actionType) {
this.actionType = actionType;
setHeader(new Header(MessageType.BOAT_ACTION, 0, (short) 1)); // the second variable is the source id
allocateBuffer();