Added MessageDecoder interface. All decoder implement this.
Added DecoderFactory. This creates an appropriate decoder based on a MessageType. BoatActionDecoder implements MessageDecoder. BoatLocationDecoder implements MessageDecoder. HeartBeatDecoder implements MessageDecoder. JoinAcceptance implements MessageDecoder. RaceStatusDecoder implements MessageDecoder. RequestToJoinDecoder implements MessageDecoder. XMLMessageDecoder implements MessageDecoder. Refactored CourseWind decoder/encoder. CourseWind decoder/encoder is for an individual CourseWind. CourseWinds decoder/encoder is for the combined message from the API. Documented BoatAction, and it now contains a BoatActionEnum instead of a byte. Refactored CourseWind and CourseWinds classes. They now expose correct units, instead of packed units. Added CourseWindDecoderTest, and updated CourseWindsDecoderTest. issue #35 #36 #story[1095]
This commit is contained in:
@@ -2,6 +2,7 @@ package visualiser.gameController;
|
||||
|
||||
import network.BinaryMessageDecoder;
|
||||
import network.MessageDecoders.BoatActionDecoder;
|
||||
import network.Messages.BoatAction;
|
||||
import network.Messages.Enums.BoatActionEnum;
|
||||
import visualiser.gameController.Keys.ControlKey;
|
||||
import visualiser.gameController.Keys.KeyFactory;
|
||||
@@ -47,9 +48,10 @@ public class ControllerServer implements Runnable {
|
||||
if (inputStream.available() > 0) {
|
||||
inputStream.read(message);
|
||||
BinaryMessageDecoder encodedMessage = new BinaryMessageDecoder(message);
|
||||
BoatActionDecoder boatActionDecoder = new BoatActionDecoder(encodedMessage.getMessageBody());
|
||||
BoatActionEnum decodedMessage = boatActionDecoder.getBoatAction();
|
||||
System.out.println("Received key: " + decodedMessage);
|
||||
BoatActionDecoder boatActionDecoder = new BoatActionDecoder();
|
||||
boatActionDecoder.decode(encodedMessage.getMessageBody());
|
||||
BoatAction boatAction = boatActionDecoder.getMessage();
|
||||
System.out.println("Received key: " + boatAction.getBoatAction());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user