Implemented RequestToJoin and JoinAcceptance messages.
Also added their message types to MessageType. issue #35 #story[1095]
This commit is contained in:
@@ -19,6 +19,17 @@ public enum MessageType {
|
|||||||
MARKROUNDING(38),
|
MARKROUNDING(38),
|
||||||
COURSEWIND(44),
|
COURSEWIND(44),
|
||||||
AVGWIND(47),
|
AVGWIND(47),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is used for {@link network.Messages.RequestToJoin} messages.
|
||||||
|
*/
|
||||||
|
REQUEST_TO_JOIN(55),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is used for {@link network.Messages.JoinAcceptance} messages.
|
||||||
|
*/
|
||||||
|
JOIN_ACCEPTANCE(56),
|
||||||
|
|
||||||
BOATACTION(100),
|
BOATACTION(100),
|
||||||
NOTAMESSAGE(0);
|
NOTAMESSAGE(0);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,53 @@
|
|||||||
package network.Messages;
|
package network.Messages;
|
||||||
|
|
||||||
public class JoinAcceptance {
|
import network.Messages.Enums.JoinAcceptanceEnum;
|
||||||
|
import network.Messages.Enums.MessageType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the message a server sends to a client to tell them their boat sourceID, and if they have actually managed to join the server.
|
||||||
|
*/
|
||||||
|
public class JoinAcceptance extends AC35Data {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The source ID of the boat assigned to the client.
|
||||||
|
* 0 indicates they haven't been assigned a boat.
|
||||||
|
*/
|
||||||
|
private int sourceID = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of acceptance response this is.
|
||||||
|
*/
|
||||||
|
private JoinAcceptanceEnum acceptanceType;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a JoinAcceptance message of a given acceptance type.
|
||||||
|
* @param acceptanceType The type of join acceptance this is.
|
||||||
|
*/
|
||||||
|
public JoinAcceptance(JoinAcceptanceEnum acceptanceType, int sourceID){
|
||||||
|
super(MessageType.JOIN_ACCEPTANCE);
|
||||||
|
this.acceptanceType = acceptanceType;
|
||||||
|
this.sourceID = sourceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of acceptance response this is.
|
||||||
|
* @return The type of acceptance response.
|
||||||
|
*/
|
||||||
|
public JoinAcceptanceEnum getAcceptanceType() {
|
||||||
|
return acceptanceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the source ID of the boat assigned to the client.
|
||||||
|
* @return The source ID of the boat assigned to the client.
|
||||||
|
*/
|
||||||
|
public int getSourceID() {
|
||||||
|
return sourceID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,36 @@
|
|||||||
package network.Messages;
|
package network.Messages;
|
||||||
|
|
||||||
|
|
||||||
|
import network.Messages.Enums.MessageType;
|
||||||
|
import network.Messages.Enums.RequestToJoinEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the message a client sends to a server to request to join/view a race.
|
* This is the message a client sends to a server to request to join/view a race.
|
||||||
*/
|
*/
|
||||||
public class RequestToJoin {
|
public class RequestToJoin extends AC35Data {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of join request this is.
|
||||||
|
*/
|
||||||
|
private RequestToJoinEnum requestType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a RequestToJoin message of a given request type.
|
||||||
|
* @param requestType The type of join request this is.
|
||||||
|
*/
|
||||||
|
public RequestToJoin(RequestToJoinEnum requestType){
|
||||||
|
super(MessageType.REQUEST_TO_JOIN);
|
||||||
|
this.requestType = requestType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of join request this is.
|
||||||
|
* @return The type of join request.
|
||||||
|
*/
|
||||||
|
public RequestToJoinEnum getRequestType() {
|
||||||
|
return requestType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user