Added REQUEST_RECEIVED and DECLINED to ConnnectionStateEnum.
#story[1095]
This commit is contained in:
@@ -19,8 +19,10 @@ import javax.xml.transform.TransformerException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -70,7 +72,7 @@ public class Event {
|
|||||||
*/
|
*/
|
||||||
public Event(boolean singlePlayer) throws EventConstructionException {
|
public Event(boolean singlePlayer) throws EventConstructionException {
|
||||||
|
|
||||||
singlePlayer = false;
|
singlePlayer = false;//TEMP
|
||||||
|
|
||||||
String raceXMLFile = "mock/mockXML/raceTest.xml";
|
String raceXMLFile = "mock/mockXML/raceTest.xml";
|
||||||
String boatsXMLFile = "mock/mockXML/boatTest.xml";
|
String boatsXMLFile = "mock/mockXML/boatTest.xml";
|
||||||
@@ -154,14 +156,6 @@ public class Event {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getAddress() throws UnknownHostException {
|
|
||||||
return connectionAcceptor.getAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPort() {
|
|
||||||
return connectionAcceptor.getServerPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends the initial race data and then begins race simulation.
|
* Sends the initial race data and then begins race simulation.
|
||||||
*/
|
*/
|
||||||
@@ -190,7 +184,7 @@ public class Event {
|
|||||||
private String getRaceXMLAtCurrentTime(String raceXML) {
|
private String getRaceXMLAtCurrentTime(String raceXML) {
|
||||||
|
|
||||||
//The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute.
|
//The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute.
|
||||||
long millisecondsToAdd = Constants.RacePreStartTime + (1 * 60 * 1000);
|
long millisecondsToAdd = Constants.RacePreStartTime + Duration.ofMinutes(1).toMillis();
|
||||||
long secondsToAdd = millisecondsToAdd / 1000;
|
long secondsToAdd = millisecondsToAdd / 1000;
|
||||||
//Scale the time using our time scalar.
|
//Scale the time using our time scalar.
|
||||||
secondsToAdd = secondsToAdd / Constants.RaceTimeScale;
|
secondsToAdd = secondsToAdd / Constants.RaceTimeScale;
|
||||||
|
|||||||
@@ -16,14 +16,25 @@ public enum ConnectionStateEnum {
|
|||||||
WAITING_FOR_HANDSHAKE(1),
|
WAITING_FOR_HANDSHAKE(1),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client has completed the handshake, and is connected.
|
* The server has receved a {@link network.Messages.RequestToJoin} from the client.
|
||||||
*/
|
*/
|
||||||
CONNECTED(2),
|
REQUEST_RECEIVED(2),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The client has completed the handshake, and is connected.
|
||||||
|
* That is, the client sent a {@link network.Messages.RequestToJoin}, which was successful, and the server responded with a {@link network.Messages.JoinAcceptance}.
|
||||||
|
*/
|
||||||
|
CONNECTED(3),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client has timed out.
|
* The client has timed out.
|
||||||
*/
|
*/
|
||||||
TIMED_OUT(3);
|
TIMED_OUT(4),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The client's connection has been declined.
|
||||||
|
*/
|
||||||
|
DECLINED(5);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
package shared.model;
|
package shared.model;
|
||||||
|
|
||||||
|
|
||||||
import network.Exceptions.InvalidMessageException;
|
|
||||||
import network.MessageEncoders.RaceVisionByteEncoder;
|
|
||||||
import network.Messages.AC35Data;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user