Small changes
This commit is contained in:
@@ -8,10 +8,7 @@ import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseSta
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Abstract class representing a packet in the Open Autonomous Connection (OAC) protocol.
|
||||
@@ -23,7 +20,7 @@ public abstract class OACPacket extends Packet {
|
||||
* The protocol version associated with this packet.
|
||||
*/
|
||||
@Getter
|
||||
private final ProtocolVersion protocolVersion;
|
||||
private final List<ProtocolVersion> compatibleVersions;
|
||||
private final int id;
|
||||
/**
|
||||
* The response code for the packet, defaulting to RESPONSE_NOT_REQUIRED.
|
||||
@@ -34,11 +31,11 @@ public abstract class OACPacket extends Packet {
|
||||
* Constructor for OACPacket.
|
||||
*
|
||||
* @param id The unique identifier for the packet.
|
||||
* @param protocolVersion The protocol version associated with this packet.
|
||||
* @param supportedVersions The protocol version associated with this packet.
|
||||
*/
|
||||
public OACPacket(int id, ProtocolVersion protocolVersion) {
|
||||
public OACPacket(int id, ProtocolVersion... supportedVersions) {
|
||||
this.id = id;
|
||||
this.protocolVersion = protocolVersion;
|
||||
this.compatibleVersions = List.of(supportedVersions);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,7 +73,7 @@ public abstract class OACPacket extends Packet {
|
||||
onWrite(outputStream);
|
||||
|
||||
// Write the response code if the protocol version is not classic
|
||||
if (protocolVersion != ProtocolVersion.PV_1_0_0_CLASSIC) outputStream.writeUTF(responseCode.name());
|
||||
if (!compatibleVersions.contains(ProtocolVersion.PV_1_0_0_CLASSIC)) outputStream.writeUTF(responseCode.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +82,7 @@ public abstract class OACPacket extends Packet {
|
||||
onRead(inputStream, clientID);
|
||||
|
||||
// Read the response code if the protocol version is not classic
|
||||
if (protocolVersion != ProtocolVersion.PV_1_0_0_CLASSIC)
|
||||
if (!compatibleVersions.contains(ProtocolVersion.PV_1_0_0_CLASSIC))
|
||||
responseCode = INSResponseStatus.valueOf(inputStream.readUTF());
|
||||
else responseCode = INSResponseStatus.RESPONSE_NOT_REQUIRED;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user