Removed ProtocolBridge#getInstance

This commit is contained in:
Finn
2025-12-08 10:33:46 +01:00
parent 2ea23885fd
commit ca3bc2e2c5
21 changed files with 248 additions and 112 deletions

View File

@@ -310,7 +310,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
*/
public final void validateInfoName(InfoName infoName) throws IOException, ClassNotFoundException {
// Send Classic_PingPacket if classic protocol is supported
Classic_PingPacket cPingPacket = new Classic_PingPacket(new Classic_RequestDomain(infoName.getName(), infoName.getTopLevelName(), infoName.getPath()), null, false);
Classic_PingPacket cPingPacket = new Classic_PingPacket(new Classic_RequestDomain(infoName.getName(), infoName.getTopLevelName(), infoName.getPath(), protocolBridge), null, false, protocolBridge);
if (protocolBridge.isClassicSupported()) clientToINS.sendPacket(cPingPacket);
// Send ValidateInfoNamePacket
@@ -327,16 +327,16 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
*/
public final void requestInfoName(InfoName infoName, INSResponseCode responseCode) throws IOException, ClassNotFoundException {
// Send Classic_DomainPacket if classic protocol is supported
Classic_DomainPacket cDomainPacket = new Classic_DomainPacket(0, new Classic_RequestDomain(infoName.getName(), infoName.getTopLevelName(), infoName.getPath()), null);
Classic_DomainPacket cDomainPacket = new Classic_DomainPacket(0, new Classic_RequestDomain(infoName.getName(), infoName.getTopLevelName(), infoName.getPath(), protocolBridge), null, protocolBridge);
if (protocolBridge.isClassicSupported()) clientToINS.sendPacket(cDomainPacket);
// Send GetDestinationPacket
clientToINS.sendPacket(new GetDestinationPacket(infoName, responseCode));
clientToINS.sendPacket(new GetDestinationPacket(infoName, responseCode, protocolBridge));
}
/**
* Set protocol bridge
* @param protocolBridge The ProtocolBridge object
* Set protocol bridge.
* @param protocolBridge The ProtocolBridge object.
*/
public void setProtocolBridge(ProtocolBridge protocolBridge) {
if (this.protocolBridge == null) this.protocolBridge = protocolBridge;

View File

@@ -2,6 +2,7 @@ package org.openautonomousconnection.protocol.side.client;
import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient;
import lombok.Getter;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.InfoName;
@@ -65,7 +66,7 @@ public final class WebClient {
// Set logger from ProtocolBridge
setLogger(protocolClient.getProtocolBridge().getLogger()).
// Set the destination and port for the pipeline connection
setHost(infoName.getDestination()).setPort(pipelinePort).
setHost(infoName.getDestination(protocolClient.getProtocolBridge())).setPort(pipelinePort).
// Configure packet handler and event manager
setPacketHandler(protocolClient.getProtocolBridge().getProtocolSettings().packetHandler).
@@ -107,10 +108,10 @@ public final class WebClient {
// Create raw socket and wrap it in SSL socket
if (proxy != null) {
Socket rawSocket = new Socket(proxy);
rawSocket.connect(new InetSocketAddress(infoName.getDestination(), webPort), 0);
tempSocket = (SSLSocket) sslSocketFactory.createSocket(rawSocket, infoName.getDestination(), webPort, true);
rawSocket.connect(new InetSocketAddress(infoName.getDestination(protocolClient.getProtocolBridge()), webPort), 0);
tempSocket = (SSLSocket) sslSocketFactory.createSocket(rawSocket, infoName.getDestination(protocolClient.getProtocolBridge()), webPort, true);
} else {
tempSocket = (SSLSocket) sslSocketFactory.createSocket(infoName.getDestination(), webPort);
tempSocket = (SSLSocket) sslSocketFactory.createSocket(infoName.getDestination(protocolClient.getProtocolBridge()), webPort);
}
clientToWebServer = tempSocket;

View File

@@ -1,7 +1,9 @@
package org.openautonomousconnection.protocol.side.client.events;
import dev.unlegitdqrk.unlegitlibrary.event.impl.Event;
import lombok.Getter;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
/**
@@ -9,4 +11,15 @@ import org.openautonomousconnection.protocol.versions.ProtocolVersion;
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
public final class ConnectedToProtocolINSServerEvent extends Event {
/**
* Reference to the ProtocolClient object.
*/
@Getter
private final ProtocolClient client;
public ConnectedToProtocolINSServerEvent(ProtocolClient client) {
this.client = client;
}
}

View File

@@ -189,7 +189,7 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
/**
* @param infoName The InfoName to look up.
* @return The destination associated with the InfoName.
* @see InfoName#getDestination()
* @see InfoName#getDestination(ProtocolBridge)
* Abstract method to get the destination for a given InfoName.
*/
public abstract String getInfoNameDestination(InfoName infoName);
@@ -198,7 +198,7 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
* @param infoName The parent InfoName.
* @param subname The subname to look up.
* @return The destination associated with the subname.
* @see InfoName#getDestination()
* @see InfoName#getDestination(ProtocolBridge)
* Abstract method to get the destination for a given subname under a specific InfoName.
*/
public abstract String getSubnameDestination(InfoName infoName, String subname);
@@ -206,7 +206,7 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
/**
* @param topLevelName The top-level name.
* @return The information site URL for the specified top-level name.
* @see InfoName#getDestination()
* @see InfoName#getDestination(ProtocolBridge)
* Abstract method to get the top-level name information site URL.
*/
public abstract String getTLNInfoSite(String topLevelName);