Print statements now print off the actual key action. #story[1089]

main
Joseph Gardner 9 years ago
parent f91f7055de
commit 67c7c88b32

@ -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();

Loading…
Cancel
Save