Files
Protocol/src/main/java/org/openautonomousconnection/protocol/ProtocolBridge.java

373 lines
20 KiB
Java
Raw Normal View History

2025-09-24 22:02:10 +02:00
package org.openautonomousconnection.protocol;
2025-09-19 21:27:35 +02:00
import dev.unlegitdqrk.unlegitlibrary.addon.AddonLoader;
2026-02-11 23:11:33 +01:00
import dev.unlegitdqrk.unlegitlibrary.file.FileUtils;
import dev.unlegitdqrk.unlegitlibrary.network.system.utils.ClientAuthMode;
2025-09-25 23:41:17 +02:00
import dev.unlegitdqrk.unlegitlibrary.utils.Logger;
import lombok.Getter;
2025-09-29 13:18:15 +02:00
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
2025-09-24 22:02:10 +02:00
import org.openautonomousconnection.protocol.listeners.ClientListener;
2026-01-18 18:17:35 +01:00
import org.openautonomousconnection.protocol.listeners.CustomServerListener;
2025-09-24 22:02:10 +02:00
import org.openautonomousconnection.protocol.packets.OACPacket;
2026-01-18 18:17:35 +01:00
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.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_v1_0_0_B;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.stream.WebStreamEndPacket_v1_0_0_B;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.stream.WebStreamStartPacket_v1_0_0_B;
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.document.WebDocumentApplyRequestPacket;
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.document.WebDocumentApplyResponsePacket;
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.document.WebDocumentSnapshotEventPacket;
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.navigate.WebNavigateAckPacket;
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.navigate.WebNavigateRequestPacket;
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceRequestPacket;
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceResponsePacket;
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.stream.WebStreamChunkPacket_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;
2025-09-24 22:02:10 +02:00
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
2026-02-22 14:49:10 +01:00
import org.openautonomousconnection.protocol.side.client.ProtocolWebClient;
2025-12-08 09:59:58 +01:00
import org.openautonomousconnection.protocol.side.ins.ProtocolINSServer;
2026-01-18 18:17:35 +01:00
import org.openautonomousconnection.protocol.side.server.ProtocolCustomServer;
2026-02-22 14:49:10 +01:00
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
2025-09-24 22:02:10 +02:00
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.ProtocolWebServer_1_0_0_B;
2025-09-19 21:27:35 +02:00
import java.io.File;
import java.io.IOException;
import java.util.function.Supplier;
2025-09-19 21:27:35 +02:00
2025-09-29 17:46:30 +02:00
/**
* The main bridge class for the protocol connection.
* It manages the protocol settings, version, and side instances.
*/
2025-09-29 17:56:51 +02:00
public final class ProtocolBridge {
2025-09-29 17:46:30 +02:00
/**
* The protocol settings for the current connection
*/
2025-09-19 21:27:35 +02:00
@Getter
private final ProtocolValues protocolValues;
2025-09-29 17:46:30 +02:00
/**
* The protocol version for the current connection
*/
2025-09-19 21:27:35 +02:00
@Getter
private final ProtocolVersion protocolVersion;
2025-09-29 17:46:30 +02:00
/**
* The logger instance for logging events and errors
*/
2025-09-20 20:42:58 +02:00
@Getter
2025-09-29 17:46:30 +02:00
private Logger logger;
/**
* The protocol side instances
*/
2025-09-19 21:27:35 +02:00
@Getter
private ProtocolClient protocolClient;
2025-09-29 17:46:30 +02:00
2026-01-18 18:17:35 +01:00
2025-09-29 17:46:30 +02:00
/**
* The protocol side instances
*/
2025-09-19 21:27:35 +02:00
@Getter
2026-01-18 18:17:35 +01:00
private ProtocolCustomServer protocolServer;
2025-09-29 17:46:30 +02:00
2025-10-04 00:04:33 +02:00
@Getter
private AddonLoader addonLoader;
2025-10-04 00:04:33 +02:00
2025-09-29 17:46:30 +02:00
/**
2026-01-18 18:17:35 +01:00
* Initialize the ProtocolBridge instance for the client side
2025-09-29 18:46:31 +02:00
*
2026-02-06 17:59:04 +01:00
* @param protocolServer The ProtocolCustomServer instance
* @param protocolValues The ProtocolSettings instance
* @param protocolVersion The ProtocolVersion instance
* @param logger The logger
* @param addonLoader The Addon loader to load custom extensions
2025-09-29 17:46:30 +02:00
* @throws Exception if an error occurs while initializing the ProtocolBridge
*/
public ProtocolBridge(ProtocolCustomServer protocolServer, ProtocolValues protocolValues, ProtocolVersion protocolVersion,
Logger logger, AddonLoader addonLoader) throws Exception {
2025-09-29 17:46:30 +02:00
// Assign the parameters to the class fields
2026-01-18 18:17:35 +01:00
this.protocolServer = protocolServer;
this.protocolValues = protocolValues;
2025-09-29 13:18:15 +02:00
this.protocolVersion = protocolVersion;
this.logger = logger;
this.addonLoader = addonLoader;
2025-09-29 13:18:15 +02:00
if (protocolServer instanceof ProtocolINSServer)
protocolServer.attachBridge(this, null, false, ClientAuthMode.NONE);
else
protocolServer.attachBridge(this, protocolValues.keyPass, protocolValues.ssl, protocolValues.authMode);
2025-09-29 17:46:30 +02:00
initializeProtocolVersion();
2026-02-11 23:11:33 +01:00
downloadLicenses();
2025-09-29 17:46:30 +02:00
// Register the appropriate listeners and packets
registerListeners();
2025-09-20 20:41:08 +02:00
registerPackets();
2025-09-19 21:27:35 +02:00
}
2025-09-29 17:46:30 +02:00
/**
* Initialize the ProtocolBridge instance for the client side
2025-09-29 18:46:31 +02:00
*
2026-02-06 17:59:04 +01:00
* @param protocolClient The ProtocolClient instance
* @param protocolValues The ProtocolSettings instance
* @param protocolVersion The ProtocolVersion instance
* @param logger The logger
* @param addonLoader The Addon loader to load custom extensions
2025-09-29 17:46:30 +02:00
* @throws Exception if an error occurs while initializing the ProtocolBridge
*/
2025-09-29 13:18:15 +02:00
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.CLIENT)
public ProtocolBridge(ProtocolClient protocolClient, ProtocolValues protocolValues, ProtocolVersion protocolVersion,
Logger logger, AddonLoader addonLoader) throws Exception {
2025-09-29 17:46:30 +02:00
// Assign the parameters to the class fields
2025-09-19 21:27:35 +02:00
this.protocolClient = protocolClient;
this.protocolValues = protocolValues;
2025-09-19 21:27:35 +02:00
this.protocolVersion = protocolVersion;
this.logger = logger;
this.addonLoader = addonLoader;
2025-09-19 21:27:35 +02:00
protocolClient.attachBridge(this);
initializeProtocolVersion();
2026-02-11 23:11:33 +01:00
downloadLicenses();
2025-09-19 20:46:57 +02:00
2025-09-29 17:46:30 +02:00
// Register the appropriate listeners and packets
registerListeners();
2025-09-20 20:41:08 +02:00
registerPackets();
2025-09-19 21:27:35 +02:00
}
2026-02-11 23:11:33 +01:00
private void downloadLicenses() throws IOException {
2026-02-14 15:01:17 +01:00
File licensesFolder = new File("licenses");
2026-02-14 15:01:17 +01:00
if (!licensesFolder.exists() || !licensesFolder.isDirectory()) {
if (licensesFolder.exists()) licensesFolder.delete();
2026-02-14 15:01:17 +01:00
File output = new File("licenses.zip");
output.createNewFile();
FileUtils.downloadFile("https://open-autonomous-connection.org/assets/licenses.zip", output);
FileUtils.unzip(output, licensesFolder.getParent());
output.deleteOnExit();
}
2026-02-11 23:11:33 +01:00
}
2025-09-29 17:46:30 +02:00
/**
* Register the appropriate packets
*
* <p>Overview of all Packets
*
* <table border="2">
* <tr><th>ID</th><th>Packet</th><th>ProtocolVersion</th></tr>
*
* <tr><td>8</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_0.beta.AuthPacket AuthPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_0_BETA PV_1_0_0_BETA}</td></tr>
* <tr><td>7</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_0.beta.INSQueryPacket INSQueryPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_0_BETA PV_1_0_0_BETA}</td></tr>
* <tr><td>6</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_0.beta.INSResponsePacket INSResponsePacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_0_BETA PV_1_0_0_BETA}</td></tr>
* <tr><td>10</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebRequestPacket WebRequestPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_0_BETA PV_1_0_0_BETA}</td></tr>
* <tr><td>9</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebResponsePacket WebResponsePacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_0_BETA PV_1_0_0_BETA}</td></tr>
* <tr><td>11</td><td>{@link WebStreamStartPacket_v1_0_0_B v1_0_0.beta.web.stream.WebStreamStartPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_0_BETA PV_1_0_0_BETA}</td></tr>
* <tr><td>13</td><td>{@link WebStreamChunkPacket_v1_0_0_B v1_0_0.beta.web.stream.WebStreamChunkPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_0_BETA PV_1_0_0_BETA}</td></tr>
* <tr><td>12</td><td>{@link WebStreamEndPacket_v1_0_0_B v1_0_0.beta.web.stream.WebStreamEndPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_0_BETA PV_1_0_0_BETA}</td></tr>
*
* <tr><td>1</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.navigate.WebNavigateRequestPacket WebNavigateRequestPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_1_BETA PV_1_0_1_BETA}</td></tr>
* <tr><td>2</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.navigate.WebNavigateAckPacket WebNavigateAckPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_1_BETA PV_1_0_1_BETA}</td></tr>
* <tr><td>3</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceRequestPacket WebResourceRequestPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_1_BETA PV_1_0_1_BETA}</td></tr>
* <tr><td>4</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceResponsePacket WebResourceResponsePacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_1_BETA PV_1_0_1_BETA}</td></tr>
* <tr><td>14</td><td>{@link WebStreamStartPacket_v1_0_1_B v1_0_1.beta.web.impl.stream.WebStreamStartPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_1_BETA PV_1_0_1_BETA}</td></tr>
* <tr><td>15</td><td>{@link WebStreamChunkPacket_v1_0_1_B v1_0_1.beta.web.impl.stream.WebStreamChunkPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_1_BETA PV_1_0_1_BETA}</td></tr>
* <tr><td>16</td><td>{@link WebStreamEndPacket_v1_0_1_B v1_0_1.beta.web.impl.stream.WebStreamEndPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_1_BETA PV_1_0_1_BETA}</td></tr>
* <tr><td>17</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.document.WebDocumentSnapshotEventPacket WebDocumentSnapshotEventPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_1_BETA PV_1_0_1_BETA}</td></tr>
* <tr><td>5</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.document.WebDocumentApplyResponsePacket WebDocumentApplyResponsePacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_1_BETA PV_1_0_1_BETA}</td></tr>
* <tr><td>18</td><td>{@link org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.document.WebDocumentApplyRequestPacket WebDocumentApplyRequestPacket}</td><td>{@link org.openautonomousconnection.protocol.versions.ProtocolVersion#PV_1_0_1_BETA PV_1_0_1_BETA}</td></tr>
* </table>
*
* @see org.openautonomousconnection.protocol.versions.ProtocolVersion
2025-09-29 17:46:30 +02:00
*/
2025-09-20 20:41:08 +02:00
private void registerPackets() {
// 1.0.0-BETA packets
registerPacket(AuthPacket::new);
registerPacket(INSQueryPacket::new);
registerPacket(() -> new INSResponsePacket(this));
registerPacket(WebRequestPacket::new);
registerPacket(WebResponsePacket::new);
registerPacket(WebStreamStartPacket_v1_0_0_B::new);
registerPacket(WebStreamChunkPacket_v1_0_0_B::new);
registerPacket(WebStreamEndPacket_v1_0_0_B::new);
// 1.0.1-BETA Packets
registerPacket(WebDocumentApplyRequestPacket::new);
registerPacket(WebDocumentApplyResponsePacket::new);
registerPacket(WebDocumentSnapshotEventPacket::new);
registerPacket(WebNavigateRequestPacket::new);
registerPacket(WebNavigateAckPacket::new);
registerPacket(WebResourceRequestPacket::new);
registerPacket(WebResourceResponsePacket::new);
registerPacket(WebStreamStartPacket_v1_0_1_B::new);
registerPacket(WebStreamChunkPacket_v1_0_1_B::new);
registerPacket(WebStreamEndPacket_v1_0_1_B::new);
2025-09-20 20:41:08 +02:00
}
private void registerPacket(Supplier<? extends OACPacket> factory) {
if (isPacketSupported(factory.get())) protocolValues.packetHandler.registerPacket(factory);
}
2025-09-29 17:46:30 +02:00
/**
* Register the appropriate listeners based on the current side
2025-09-29 18:46:31 +02:00
*
2025-09-29 17:46:30 +02:00
* @throws Exception if an error occurs while registering the listeners
*/
private void registerListeners() throws Exception {
// Client Listeners
if (isRunningAsClient()) {
protocolValues.eventManager.registerListener(new ClientListener(protocolClient));
protocolValues.eventManager.unregisterListener(CustomServerListener.class);
2026-01-18 18:17:35 +01:00
}
// Server Listeners
if (isRunningAsServer()) {
protocolValues.eventManager.registerListener(new CustomServerListener(protocolServer));
protocolValues.eventManager.unregisterListener(ClientListener.class);
2025-09-29 17:46:30 +02:00
}
}
/**
* Initialize the protocol version
* Validate if the protocol version is valid for the current side
* If not, log an error and exit the application
*/
private void initializeProtocolVersion() {
// Check if the protocol version is valid for the current side
// If not, log an error and exit the application
if (!validateProtocolSide()) {
this.logger.error("Invalid protocol version '" + protocolVersion.toString() + "'!");
System.exit(1);
}
2025-09-20 15:17:36 +02:00
}
2025-09-29 17:46:30 +02:00
/**
* Check if the classic protocol is supported by the current protocol version
2025-09-29 18:46:31 +02:00
*
2025-09-29 17:46:30 +02:00
* @return true if the classic protocol is supported, false otherwise
*/
2025-09-29 18:46:31 +02:00
public boolean isClassicSupported() {
boolean yes = false;
for (ProtocolVersion compatibleVersion : protocolVersion.getCompatibleVersions()) {
2025-09-29 17:46:30 +02:00
// Check if the compatible version is classic
yes = compatibleVersion.getProtocolType() == ProtocolVersion.ProtocolType.CLASSIC;
if (yes) break;
}
2025-09-29 17:46:30 +02:00
// Check if the current protocol version is classic or if it is supported by any of the compatible versions
return protocolVersion.getProtocolType() == ProtocolVersion.ProtocolType.CLASSIC || yes;
}
2025-09-29 17:46:30 +02:00
/**
* Check if the target protocol is supported by the current protocol version
2025-09-29 18:46:31 +02:00
*
2025-09-29 17:46:30 +02:00
* @param protocol The target protocol to check
* @return true If the target protocol is supported, false otherwise
*/
2025-09-29 18:46:31 +02:00
public boolean isProtocolSupported(ProtocolVersion.Protocol protocol) {
2025-09-25 23:40:24 +02:00
boolean yes = false;
2025-09-25 23:40:24 +02:00
for (ProtocolVersion compatibleVersion : protocolVersion.getCompatibleVersions()) {
2025-09-29 17:46:30 +02:00
// Check if the compatible version supports the target protocol
2025-09-25 23:40:24 +02:00
yes = compatibleVersion.getSupportedProtocols().contains(protocol);
if (yes) break;
}
2025-09-29 17:46:30 +02:00
// Check if the current protocol version supports the target protocol or if it is supported by any of the compatible versions
2025-09-25 23:40:24 +02:00
return protocolVersion.getSupportedProtocols().contains(protocol) || yes;
}
2025-09-29 17:46:30 +02:00
/**
* Check if the target packet is supported by the current protocol version
2025-09-29 18:46:31 +02:00
*
2025-09-29 17:46:30 +02:00
* @param packet The target packet to check
* @return true if the target packet is supported, false otherwise
*/
2025-09-29 18:46:31 +02:00
public boolean isPacketSupported(OACPacket packet) {
2026-02-22 14:49:10 +01:00
boolean compatible = false;
for (ProtocolVersion compatibleVersion : packet.getCompatibleVersions()) {
if (!compatible) compatible = isVersionSupported(compatibleVersion);
}
return compatible;
2025-09-19 21:27:35 +02:00
}
2025-09-29 17:46:30 +02:00
/**
* Check if the target protocol version is supported by the current protocol version
2025-09-29 18:46:31 +02:00
*
2025-09-29 17:46:30 +02:00
* @param targetVersion The target protocol version to check
* @return true if the target protocol version is supported, false otherwise
*/
2025-09-29 18:46:31 +02:00
public boolean isVersionSupported(ProtocolVersion targetVersion) {
2025-09-29 17:46:30 +02:00
// Check if the target protocol version is the same as the current protocol version or if it is in the list of compatible versions
return protocolVersion == targetVersion || protocolVersion.getCompatibleVersions().contains(targetVersion);
2025-09-25 23:40:24 +02:00
}
2025-09-29 17:46:30 +02:00
/**
* Validate if the protocol version is valid for the current side
2025-09-29 18:46:31 +02:00
*
2025-09-29 17:46:30 +02:00
* @return true if the protocol version is valid for the current side, false otherwise
*/
2025-09-20 15:17:36 +02:00
private boolean validateProtocolSide() {
2025-09-25 23:40:24 +02:00
return
(isRunningAsClient() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT) ||
2025-09-25 23:41:17 +02:00
(isRunningAsClient() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT_WEB) ||
2025-12-08 09:59:58 +01:00
(isRunningAsClient() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT_INS) ||
2025-09-25 23:41:17 +02:00
(isRunningAsClient() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.ALL) ||
(isRunningAsWebServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.WEB) ||
(isRunningAsWebServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT_WEB) ||
2025-12-08 09:59:58 +01:00
(isRunningAsWebServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.WEB_INS) ||
2025-09-25 23:41:17 +02:00
(isRunningAsWebServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.ALL) ||
2026-01-18 18:17:35 +01:00
(isRunningAsServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.ALL) ||
2025-12-08 09:59:58 +01:00
(isRunningAsINSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.INS) ||
(isRunningAsINSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.WEB_INS) ||
(isRunningAsINSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT_INS) ||
(isRunningAsINSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.ALL);
2025-09-19 21:27:35 +02:00
}
2025-09-29 17:46:30 +02:00
/**
2025-12-08 09:59:58 +01:00
* Check if the current instance is running as a INS server
2025-09-29 18:46:31 +02:00
*
2025-12-08 09:59:58 +01:00
* @return true if the current instance is running as a INS server, false otherwise
2025-09-29 17:46:30 +02:00
*/
2025-12-08 09:59:58 +01:00
public boolean isRunningAsINSServer() {
2026-01-18 18:17:35 +01:00
return isRunningAsServer() && protocolServer instanceof ProtocolINSServer;
2025-09-29 17:46:30 +02:00
}
/**
* Check if the current instance is running as a client
2025-09-29 18:46:31 +02:00
*
2025-09-29 17:46:30 +02:00
* @return true if the current instance is running as a client, false otherwise
*/
2025-09-29 18:46:31 +02:00
public boolean isRunningAsClient() {
2025-09-29 17:46:30 +02:00
return protocolClient != null;
}
/**
* Check if the current instance is running as a web server
2025-09-29 18:46:31 +02:00
*
2025-09-29 17:46:30 +02:00
* @return true if the current instance is running as a web server, false otherwise
*/
2025-09-29 18:46:31 +02:00
public boolean isRunningAsWebServer() {
2026-02-22 14:49:10 +01:00
return isRunningAsServer() && protocolServer instanceof ProtocolWebServer;
2026-01-18 18:17:35 +01:00
}
/**
* Check if the current instance is running as a custom server
*
* @return true if the current instance is running as a custom server, false otherwise
*/
public boolean isRunningAsServer() {
return protocolServer != null;
2025-09-19 21:27:35 +02:00
}
}