Small changes
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>org.openautonomousconnection</groupId>
|
<groupId>org.openautonomousconnection</groupId>
|
||||||
<artifactId>Protocol</artifactId>
|
<artifactId>Protocol</artifactId>
|
||||||
<version>1.0.1-BETA.0.1</version>
|
<version>1.0.1-BETA.0.2</version>
|
||||||
<organization>
|
<organization>
|
||||||
<name>Open Autonomous Connection</name>
|
<name>Open Autonomous Connection</name>
|
||||||
<url>https://open-autonomous-connection.org/</url>
|
<url>https://open-autonomous-connection.org/</url>
|
||||||
|
|||||||
@@ -28,8 +28,10 @@ import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.stream
|
|||||||
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.stream.WebStreamEndPacket_v1_0_1_B;
|
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.stream.WebStreamEndPacket_v1_0_1_B;
|
||||||
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.stream.WebStreamStartPacket_v1_0_1_B;
|
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.stream.WebStreamStartPacket_v1_0_1_B;
|
||||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
||||||
|
import org.openautonomousconnection.protocol.side.client.ProtocolWebClient;
|
||||||
import org.openautonomousconnection.protocol.side.ins.ProtocolINSServer;
|
import org.openautonomousconnection.protocol.side.ins.ProtocolINSServer;
|
||||||
import org.openautonomousconnection.protocol.side.server.ProtocolCustomServer;
|
import org.openautonomousconnection.protocol.side.server.ProtocolCustomServer;
|
||||||
|
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
|
||||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.ProtocolWebServer_1_0_0_B;
|
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.ProtocolWebServer_1_0_0_B;
|
||||||
|
|
||||||
@@ -287,7 +289,13 @@ public final class ProtocolBridge {
|
|||||||
* @return true if the target packet is supported, false otherwise
|
* @return true if the target packet is supported, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isPacketSupported(OACPacket packet) {
|
public boolean isPacketSupported(OACPacket packet) {
|
||||||
return isVersionSupported(packet.getProtocolVersion());
|
boolean compatible = false;
|
||||||
|
|
||||||
|
for (ProtocolVersion compatibleVersion : packet.getCompatibleVersions()) {
|
||||||
|
if (!compatible) compatible = isVersionSupported(compatibleVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
return compatible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -350,7 +358,7 @@ public final class ProtocolBridge {
|
|||||||
* @return true if the current instance is running as a web server, false otherwise
|
* @return true if the current instance is running as a web server, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isRunningAsWebServer() {
|
public boolean isRunningAsWebServer() {
|
||||||
return isRunningAsServer() && protocolServer instanceof ProtocolWebServer_1_0_0_B;
|
return isRunningAsServer() && protocolServer instanceof ProtocolWebServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,10 +8,7 @@ import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseSta
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class representing a packet in the Open Autonomous Connection (OAC) protocol.
|
* 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.
|
* The protocol version associated with this packet.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private final ProtocolVersion protocolVersion;
|
private final List<ProtocolVersion> compatibleVersions;
|
||||||
private final int id;
|
private final int id;
|
||||||
/**
|
/**
|
||||||
* The response code for the packet, defaulting to RESPONSE_NOT_REQUIRED.
|
* The response code for the packet, defaulting to RESPONSE_NOT_REQUIRED.
|
||||||
@@ -34,11 +31,11 @@ public abstract class OACPacket extends Packet {
|
|||||||
* Constructor for OACPacket.
|
* Constructor for OACPacket.
|
||||||
*
|
*
|
||||||
* @param id The unique identifier for the packet.
|
* @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.id = id;
|
||||||
this.protocolVersion = protocolVersion;
|
this.compatibleVersions = List.of(supportedVersions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,7 +73,7 @@ public abstract class OACPacket extends Packet {
|
|||||||
onWrite(outputStream);
|
onWrite(outputStream);
|
||||||
|
|
||||||
// Write the response code if the protocol version is not classic
|
// 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
|
@Override
|
||||||
@@ -85,7 +82,7 @@ public abstract class OACPacket extends Packet {
|
|||||||
onRead(inputStream, clientID);
|
onRead(inputStream, clientID);
|
||||||
|
|
||||||
// Read the response code if the protocol version is not classic
|
// 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());
|
responseCode = INSResponseStatus.valueOf(inputStream.readUTF());
|
||||||
else responseCode = INSResponseStatus.RESPONSE_NOT_REQUIRED;
|
else responseCode = INSResponseStatus.RESPONSE_NOT_REQUIRED;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public final class AuthPacket extends OACPacket {
|
|||||||
* Registration constructor.
|
* Registration constructor.
|
||||||
*/
|
*/
|
||||||
public AuthPacket() {
|
public AuthPacket() {
|
||||||
super(8, ProtocolVersion.PV_1_0_0_BETA);
|
super(8, ProtocolVersion.PV_1_0_0_BETA, ProtocolVersion.PV_1_0_1_BETA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public final class INSQueryPacket extends OACPacket {
|
|||||||
* Registration constructor
|
* Registration constructor
|
||||||
*/
|
*/
|
||||||
public INSQueryPacket() {
|
public INSQueryPacket() {
|
||||||
super(7, ProtocolVersion.PV_1_0_0_BETA);
|
super(7, ProtocolVersion.PV_1_0_0_BETA, ProtocolVersion.PV_1_0_1_BETA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public final class INSResponsePacket extends OACPacket {
|
|||||||
* @param bridge Protocol runtime context.
|
* @param bridge Protocol runtime context.
|
||||||
*/
|
*/
|
||||||
public INSResponsePacket(ProtocolBridge bridge) {
|
public INSResponsePacket(ProtocolBridge bridge) {
|
||||||
super(6, ProtocolVersion.PV_1_0_0_BETA);
|
super(6, ProtocolVersion.PV_1_0_0_BETA, ProtocolVersion.PV_1_0_1_BETA);
|
||||||
this.bridge = bridge;
|
this.bridge = bridge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -229,7 +229,13 @@ public abstract class ProtocolClient extends EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean supportINSServerPacket(OACPacket packet) {
|
public final boolean supportINSServerPacket(OACPacket packet) {
|
||||||
return supportINSServerVersion(packet.getProtocolVersion());
|
boolean compatible = false;
|
||||||
|
|
||||||
|
for (ProtocolVersion compatibleVersion : packet.getCompatibleVersions()) {
|
||||||
|
if (!compatible) compatible = supportINSServerVersion(compatibleVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
return compatible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean supportINSServerVersion(ProtocolVersion targetVersion) {
|
public final boolean supportINSServerVersion(ProtocolVersion targetVersion) {
|
||||||
@@ -285,7 +291,13 @@ public abstract class ProtocolClient extends EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean supportServerPacket(OACPacket packet) {
|
public final boolean supportServerPacket(OACPacket packet) {
|
||||||
return supportServerVersion(packet.getProtocolVersion());
|
boolean compatible = false;
|
||||||
|
|
||||||
|
for (ProtocolVersion compatibleVersion : packet.getCompatibleVersions()) {
|
||||||
|
if (!compatible) compatible = supportServerVersion(compatibleVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
return compatible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean supportServerVersion(ProtocolVersion targetVersion) {
|
public final boolean supportServerVersion(ProtocolVersion targetVersion) {
|
||||||
|
|||||||
@@ -156,7 +156,13 @@ public class CustomConnectedClient extends EventListener {
|
|||||||
* @return True if the client supports the packet's protocol version, false otherwise.
|
* @return True if the client supports the packet's protocol version, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean supportClientPacket(OACPacket packet) {
|
public boolean supportClientPacket(OACPacket packet) {
|
||||||
return supportClientVersion(packet.getProtocolVersion());
|
boolean compatible = false;
|
||||||
|
|
||||||
|
for (ProtocolVersion compatibleVersion : packet.getCompatibleVersions()) {
|
||||||
|
if (!compatible) compatible = supportClientVersion(compatibleVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
return compatible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user