Updated to latest UnlegitLibrary version and implemented UDP
This commit is contained in:
@@ -10,24 +10,16 @@ import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.AuthPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.INSQueryPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.INSResponsePacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebRequestPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebResponsePacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.stream.WebStreamChunkPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.stream.WebStreamEndPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.stream.WebStreamStartPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_DomainPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_MessagePacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_PingPacket;
|
||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
||||
import org.openautonomousconnection.protocol.side.ins.ProtocolINSServer;
|
||||
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.v1_0_0.classic.handlers.ClassicHandlerClient;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerINSServer;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerWebServer;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ClientListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -42,7 +34,7 @@ public final class ProtocolBridge {
|
||||
* The protocol settings for the current connection
|
||||
*/
|
||||
@Getter
|
||||
private final ProtocolSettings protocolSettings;
|
||||
private final ProtocolValues protocolValues;
|
||||
|
||||
/**
|
||||
* The protocol version for the current connection
|
||||
@@ -69,27 +61,6 @@ public final class ProtocolBridge {
|
||||
@Getter
|
||||
private ProtocolCustomServer protocolServer;
|
||||
|
||||
/**
|
||||
* The classic protocol handlers for INS server side
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private ClassicHandlerINSServer classicHandlerINSServer;
|
||||
|
||||
/**
|
||||
* The classic protocol handlers for web server side
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private ClassicHandlerWebServer classicHandlerWebServer;
|
||||
|
||||
/**
|
||||
* The classic protocol handlers for client side
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private ClassicHandlerClient classicHandlerClient;
|
||||
|
||||
/**
|
||||
* The proxy for client side
|
||||
*/
|
||||
@@ -101,16 +72,16 @@ public final class ProtocolBridge {
|
||||
* Initialize the ProtocolBridge instance for the client side
|
||||
*
|
||||
* @param protocolServer The ProtocolCustomServer instance
|
||||
* @param protocolSettings The ProtocolSettings instance
|
||||
* @param protocolValues The ProtocolSettings instance
|
||||
* @param protocolVersion The ProtocolVersion instance
|
||||
* @param logFolder The folder to store the log files
|
||||
* @throws Exception if an error occurs while initializing the ProtocolBridge
|
||||
*/
|
||||
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.CLIENT)
|
||||
public ProtocolBridge(ProtocolCustomServer protocolServer, ProtocolSettings protocolSettings, ProtocolVersion protocolVersion, File logFolder) throws Exception {
|
||||
public ProtocolBridge(ProtocolCustomServer protocolServer, ProtocolValues protocolValues, ProtocolVersion protocolVersion, File logFolder) throws Exception {
|
||||
// Assign the parameters to the class fields
|
||||
this.protocolServer = protocolServer;
|
||||
this.protocolSettings = protocolSettings;
|
||||
this.protocolValues = protocolValues;
|
||||
this.protocolVersion = protocolVersion;
|
||||
|
||||
// Initialize the logger and protocol version
|
||||
@@ -128,16 +99,16 @@ public final class ProtocolBridge {
|
||||
* Initialize the ProtocolBridge instance for the client side
|
||||
*
|
||||
* @param protocolClient The ProtocolClient instance
|
||||
* @param protocolSettings The ProtocolSettings instance
|
||||
* @param protocolValues The ProtocolSettings instance
|
||||
* @param protocolVersion The ProtocolVersion instance
|
||||
* @param logFolder The folder to store the log files
|
||||
* @throws Exception if an error occurs while initializing the ProtocolBridge
|
||||
*/
|
||||
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.CLIENT)
|
||||
public ProtocolBridge(ProtocolClient protocolClient, ProtocolSettings protocolSettings, ProtocolVersion protocolVersion, File logFolder) throws Exception {
|
||||
public ProtocolBridge(ProtocolClient protocolClient, ProtocolValues protocolValues, ProtocolVersion protocolVersion, File logFolder) throws Exception {
|
||||
// Assign the parameters to the class fields
|
||||
this.protocolClient = protocolClient;
|
||||
this.protocolSettings = protocolSettings;
|
||||
this.protocolValues = protocolValues;
|
||||
this.protocolVersion = protocolVersion;
|
||||
|
||||
// Initialize the logger and protocol version
|
||||
@@ -155,18 +126,8 @@ public final class ProtocolBridge {
|
||||
* Register the appropriate packets based on the current protocol version
|
||||
*/
|
||||
private void registerPackets() {
|
||||
// Classic packets
|
||||
Classic_DomainPacket cDomainPacket = new Classic_DomainPacket();
|
||||
Classic_MessagePacket cMessagePacket = new Classic_MessagePacket();
|
||||
Classic_PingPacket cPingPacket = new Classic_PingPacket();
|
||||
|
||||
if (isPacketSupported(cDomainPacket)) protocolSettings.packetHandler.registerPacket(cDomainPacket);
|
||||
if (isPacketSupported(cMessagePacket)) protocolSettings.packetHandler.registerPacket(cMessagePacket);
|
||||
if (isPacketSupported(cPingPacket)) protocolSettings.packetHandler.registerPacket(cPingPacket);
|
||||
|
||||
// 1.0.0-BETA packets
|
||||
AuthPacket v100bAuthPath = new AuthPacket();
|
||||
UnsupportedClassicPacket v100bUnsupportedClassicPacket = new UnsupportedClassicPacket();
|
||||
INSQueryPacket v100BINSQueryPacket = new INSQueryPacket();
|
||||
INSResponsePacket v100BINSResponsePacket = new INSResponsePacket(this);
|
||||
WebRequestPacket v100BWebRequestPacket = new WebRequestPacket();
|
||||
@@ -175,21 +136,19 @@ public final class ProtocolBridge {
|
||||
WebStreamStartPacket v100BStreamStartPacket = new WebStreamStartPacket();
|
||||
WebStreamEndPacket v100BStreamEndPacket = new WebStreamEndPacket();
|
||||
|
||||
if (isPacketSupported(v100bAuthPath)) protocolSettings.packetHandler.registerPacket(v100bAuthPath);
|
||||
if (isPacketSupported(v100bUnsupportedClassicPacket))
|
||||
protocolSettings.packetHandler.registerPacket(v100bUnsupportedClassicPacket);
|
||||
if (isPacketSupported(v100BINSQueryPacket)) protocolSettings.packetHandler.registerPacket(v100BINSQueryPacket);
|
||||
if (isPacketSupported(v100bAuthPath)) protocolValues.packetHandler.registerPacket(v100bAuthPath);
|
||||
if (isPacketSupported(v100BINSQueryPacket)) protocolValues.packetHandler.registerPacket(v100BINSQueryPacket);
|
||||
if (isPacketSupported(v100BINSResponsePacket))
|
||||
protocolSettings.packetHandler.registerPacket(v100BINSResponsePacket);
|
||||
protocolValues.packetHandler.registerPacket(v100BINSResponsePacket);
|
||||
if (isPacketSupported(v100BWebRequestPacket))
|
||||
protocolSettings.packetHandler.registerPacket(v100BWebRequestPacket);
|
||||
if (isPacketSupported(v100BResponsePacket)) protocolSettings.packetHandler.registerPacket(v100BResponsePacket);
|
||||
protocolValues.packetHandler.registerPacket(v100BWebRequestPacket);
|
||||
if (isPacketSupported(v100BResponsePacket)) protocolValues.packetHandler.registerPacket(v100BResponsePacket);
|
||||
if (isPacketSupported(v100BStreamChunkPacket))
|
||||
protocolSettings.packetHandler.registerPacket(v100BStreamChunkPacket);
|
||||
protocolValues.packetHandler.registerPacket(v100BStreamChunkPacket);
|
||||
if (isPacketSupported(v100BStreamStartPacket))
|
||||
protocolSettings.packetHandler.registerPacket(v100BStreamStartPacket);
|
||||
protocolValues.packetHandler.registerPacket(v100BStreamStartPacket);
|
||||
if (isPacketSupported(v100BStreamEndPacket))
|
||||
protocolSettings.packetHandler.registerPacket(v100BStreamEndPacket);
|
||||
protocolValues.packetHandler.registerPacket(v100BStreamEndPacket);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,27 +157,20 @@ public final class ProtocolBridge {
|
||||
* @throws Exception if an error occurs while registering the listeners
|
||||
*/
|
||||
private void registerListeners() throws Exception {
|
||||
// Classic listeners
|
||||
if (isClassicSupported()) {
|
||||
Classic_ClientListener classicListener = new Classic_ClientListener();
|
||||
classicListener.setProtocolBridge(this);
|
||||
protocolSettings.eventManager.registerListener(classicListener.getClass());
|
||||
} else protocolSettings.eventManager.unregisterListener(Classic_ClientListener.class);
|
||||
|
||||
// Client Listeners
|
||||
if (isRunningAsClient()) {
|
||||
ClientListener clientListener = new ClientListener();
|
||||
clientListener.setClient(protocolClient);
|
||||
protocolSettings.eventManager.registerListener(clientListener.getClass());
|
||||
protocolSettings.eventManager.unregisterListener(CustomServerListener.class);
|
||||
protocolValues.eventManager.registerListener(clientListener.getClass());
|
||||
protocolValues.eventManager.unregisterListener(CustomServerListener.class);
|
||||
}
|
||||
|
||||
// Server Listeners
|
||||
if (isRunningAsServer()) {
|
||||
CustomServerListener serverListener = new CustomServerListener();
|
||||
serverListener.setServer(protocolServer);
|
||||
protocolSettings.eventManager.registerListener(serverListener.getClass());
|
||||
protocolSettings.eventManager.unregisterListener(ClientListener.class);
|
||||
protocolValues.eventManager.registerListener(serverListener.getClass());
|
||||
protocolValues.eventManager.unregisterListener(ClientListener.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user