mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Implemented a more reliable way for keystroke input and added boat action packet type so stream parser is able to read and decode the message appropriately.
#story[988] #pair[hyi25, zyt10]
This commit is contained in:
@@ -79,8 +79,8 @@ public class StartScreenController {
|
|||||||
@FXML
|
@FXML
|
||||||
public void connectButtonPressed() {
|
public void connectButtonPressed() {
|
||||||
// TODO: 10/07/17 wmu16 - Finish function
|
// TODO: 10/07/17 wmu16 - Finish function
|
||||||
String ipAddress = ipTextField.getText().trim();
|
String ipAddress = ipTextField.getText().trim().toLowerCase();
|
||||||
StreamReceiver sr = new StreamReceiver(ipAddress, GameServerThread.PORT_NUMBER, "HostStream");
|
StreamReceiver sr = new StreamReceiver(ipAddress, 4950, "HostStream");
|
||||||
sr.start();
|
sr.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import java.util.Comparator;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
import java.util.concurrent.PriorityBlockingQueue;
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
@@ -146,6 +145,8 @@ public class StreamParser extends Thread {
|
|||||||
extractAvgWind(packet);
|
extractAvgWind(packet);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
//TODO: Haoming added something dumb here.
|
||||||
|
System.out.println(packet);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public enum PacketType {
|
|||||||
MARK_ROUNDING,
|
MARK_ROUNDING,
|
||||||
COURSE_WIND,
|
COURSE_WIND,
|
||||||
AVG_WIND,
|
AVG_WIND,
|
||||||
|
BOAT_ACTION,
|
||||||
OTHER;
|
OTHER;
|
||||||
|
|
||||||
public static PacketType assignPacketType(int packetType){
|
public static PacketType assignPacketType(int packetType){
|
||||||
@@ -44,6 +45,8 @@ public enum PacketType {
|
|||||||
return COURSE_WIND;
|
return COURSE_WIND;
|
||||||
case 47:
|
case 47:
|
||||||
return AVG_WIND;
|
return AVG_WIND;
|
||||||
|
case 100:
|
||||||
|
return BOAT_ACTION;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
return OTHER;
|
return OTHER;
|
||||||
|
|||||||
@@ -8,17 +8,18 @@ import java.nio.channels.SocketChannel;
|
|||||||
*/
|
*/
|
||||||
public class BoatActionMessage extends Message{
|
public class BoatActionMessage extends Message{
|
||||||
private final MessageType MESSAGE_TYPE = MessageType.BOAT_ACTION;
|
private final MessageType MESSAGE_TYPE = MessageType.BOAT_ACTION;
|
||||||
private final int MESSAGE_VERSION = 1; //Always set to 1
|
|
||||||
private final int MESSAGE_SIZE = 1;
|
private final int MESSAGE_SIZE = 1;
|
||||||
private BoatActionType actionType;
|
private BoatActionType actionType;
|
||||||
|
|
||||||
public BoatActionMessage(BoatActionType actionType) {
|
public BoatActionMessage(BoatActionType actionType) {
|
||||||
this.actionType = actionType;
|
this.actionType = actionType;
|
||||||
|
setHeader(new Header(MessageType.BOAT_ACTION, 0, (short) 1)); // the second variable is the source id
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return 0;
|
return MESSAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,7 +31,6 @@ public class BoatActionMessage extends Message{
|
|||||||
allocateBuffer();
|
allocateBuffer();
|
||||||
writeHeaderToBuffer();
|
writeHeaderToBuffer();
|
||||||
// Write message fields
|
// Write message fields
|
||||||
putUnsignedByte((byte) MESSAGE_VERSION);
|
|
||||||
putInt((int) BoatActionType.getBoatPacketType(actionType), 1);
|
putInt((int) BoatActionType.getBoatPacketType(actionType), 1);
|
||||||
writeCRC();
|
writeCRC();
|
||||||
rewind();
|
rewind();
|
||||||
|
|||||||
@@ -28,19 +28,6 @@
|
|||||||
<Font size="29.0" />
|
<Font size="29.0" />
|
||||||
</font>
|
</font>
|
||||||
</Text>
|
</Text>
|
||||||
<TableView fx:id="lobbyTable" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1">
|
|
||||||
<columns>
|
|
||||||
<TableColumn fx:id="ipTableColumn" prefWidth="259.0" text="IP" />
|
|
||||||
<TableColumn fx:id="colourTableColumn" prefWidth="424.0" text="Colour" />
|
|
||||||
<TableColumn fx:id="readyTableColumn" prefWidth="96.0" text="Ready" />
|
|
||||||
</columns>
|
|
||||||
<columnResizePolicy>
|
|
||||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
|
||||||
</columnResizePolicy>
|
|
||||||
<GridPane.margin>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</GridPane.margin>
|
|
||||||
</TableView>
|
|
||||||
<GridPane GridPane.rowIndex="2">
|
<GridPane GridPane.rowIndex="2">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
@@ -50,9 +37,10 @@
|
|||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Button mnemonicParsing="false" onAction="#readyButtonPressed" prefWidth="101.0" text="Ready" GridPane.halignment="CENTER" />
|
<Button focusTraversable="false" mnemonicParsing="false" onAction="#readyButtonPressed" prefWidth="101.0" text="Ready" GridPane.halignment="CENTER" />
|
||||||
<Button mnemonicParsing="false" onAction="#leaveLobbyButtonPressed" text="Leave Lobby" GridPane.columnIndex="1" GridPane.halignment="CENTER" />
|
<Button focusTraversable="false" mnemonicParsing="false" onAction="#leaveLobbyButtonPressed" text="Leave Lobby" GridPane.columnIndex="1" GridPane.halignment="CENTER" />
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
<AnchorPane focusTraversable="true" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1" />
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
|||||||
Reference in New Issue
Block a user