Merge branch 'cbt-multi-controller' of eng-git.canterbury.ac.nz:seng302-2017/team-7 into cbt-multi-controller
This commit is contained in:
@@ -52,15 +52,16 @@ public class ControllerClient {
|
|||||||
|
|
||||||
byte[] bytes = new byte[4];
|
byte[] bytes = new byte[4];
|
||||||
ByteBuffer.wrap(bytes).putInt(key.getProtocolCode());
|
ByteBuffer.wrap(bytes).putInt(key.getProtocolCode());
|
||||||
|
BoatActionEnum boatActionEnum = BoatActionEnum.fromByte(bytes[3]);
|
||||||
|
|
||||||
BoatAction boatAction = new BoatAction(BoatActionEnum.fromByte(bytes[3]));
|
BoatAction boatAction = new BoatAction(boatActionEnum);
|
||||||
|
|
||||||
byte[] encodedBoatAction = RaceVisionByteEncoder.boatActionMessage(boatAction);
|
byte[] encodedBoatAction = RaceVisionByteEncoder.boatActionMessage(boatAction);
|
||||||
|
|
||||||
BinaryMessageEncoder binaryMessage = new BinaryMessageEncoder(MessageType.BOATACTION, System.currentTimeMillis(), 0,
|
BinaryMessageEncoder binaryMessage = new BinaryMessageEncoder(MessageType.BOATACTION, System.currentTimeMillis(), 0,
|
||||||
(short) encodedBoatAction.length, encodedBoatAction);
|
(short) encodedBoatAction.length, encodedBoatAction);
|
||||||
|
|
||||||
System.out.println("Sending out key: " + protocolCode);
|
System.out.println("Sending out key: " + boatActionEnum);
|
||||||
outputStream.write(binaryMessage.getFullMessage());
|
outputStream.write(binaryMessage.getFullMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ public class ControllerServer implements Runnable {
|
|||||||
BinaryMessageDecoder encodedMessage = new BinaryMessageDecoder(message);
|
BinaryMessageDecoder encodedMessage = new BinaryMessageDecoder(message);
|
||||||
BoatActionDecoder boatActionDecoder = new BoatActionDecoder(encodedMessage.getMessageBody());
|
BoatActionDecoder boatActionDecoder = new BoatActionDecoder(encodedMessage.getMessageBody());
|
||||||
BoatActionEnum decodedMessage = boatActionDecoder.getBoatAction();
|
BoatActionEnum decodedMessage = boatActionDecoder.getBoatAction();
|
||||||
int key = decodedMessage.getValue();
|
System.out.println("Received key: " + decodedMessage);
|
||||||
System.out.println("Received key: " + key);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user