Updated to latest UnlegitLibrary version and implemented UDP
This commit is contained in:
@@ -3,6 +3,7 @@ package org.openautonomousconnection.protocol.packets.v1_0_0.beta;
|
||||
import dev.unlegitdqrk.unlegitlibrary.file.FileUtils;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.utils.ClientID;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.utils.NetworkUtils;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
@@ -93,7 +94,7 @@ public final class AuthPacket extends OACPacket {
|
||||
objectOutputStream.writeUTF(caPem);
|
||||
objectOutputStream.writeUTF(caSrl);
|
||||
} else if (protocolBridge.isRunningAsClient()) {
|
||||
objectOutputStream.writeInt(protocolBridge.getProtocolClient().getClientINSConnection().getClientID());
|
||||
objectOutputStream.writeObject(protocolBridge.getProtocolClient().getClientINSConnection().getClientId());
|
||||
objectOutputStream.writeObject(protocolBridge.getProtocolVersion());
|
||||
}
|
||||
}
|
||||
@@ -110,9 +111,9 @@ public final class AuthPacket extends OACPacket {
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
if (protocolBridge.isRunningAsServer()) {
|
||||
int clientID = objectInputStream.readInt();
|
||||
ClientID clientID = (ClientID) objectInputStream.readObject();
|
||||
ProtocolVersion clientVersion = (ProtocolVersion) objectInputStream.readObject();
|
||||
ConnectionHandler connectionHandler = protocolBridge.getProtocolServer().getPipelineServer().getConnectionHandlerByID(clientID);
|
||||
ConnectionHandler connectionHandler = protocolBridge.getProtocolServer().getNetwork().getConnectionHandlerByClientId(clientID);
|
||||
|
||||
if (!protocolBridge.isVersionSupported(clientVersion)) {
|
||||
setResponseCode(INSResponseStatus.RESPONSE_AUTH_FAILED);
|
||||
@@ -123,7 +124,7 @@ public final class AuthPacket extends OACPacket {
|
||||
|
||||
CustomConnectedClient client = protocolBridge.getProtocolServer().getClientByID(clientID);
|
||||
client.setClientVersion(clientVersion);
|
||||
protocolBridge.getProtocolSettings().eventManager.executeEvent(new S_CustomClientConnectedEvent(client));
|
||||
protocolBridge.getProtocolValues().eventManager.executeEvent(new S_CustomClientConnectedEvent(client));
|
||||
} else if (protocolBridge.isRunningAsClient()) {
|
||||
ProtocolVersion serverVersion = (ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
@@ -163,10 +164,10 @@ public final class AuthPacket extends OACPacket {
|
||||
}
|
||||
|
||||
protocolBridge.getProtocolClient().setInsServerVersion(serverVersion);
|
||||
protocolBridge.getProtocolSettings().eventManager.executeEvent(new ConnectedToProtocolINSServerEvent(protocolBridge.getProtocolClient()));
|
||||
protocolBridge.getProtocolValues().eventManager.executeEvent(new ConnectedToProtocolINSServerEvent(protocolBridge.getProtocolClient()));
|
||||
} catch (Exception ignored) {
|
||||
protocolBridge.getProtocolClient().setServerVersion(serverVersion);
|
||||
protocolBridge.getProtocolSettings().eventManager.executeEvent(new ConnectedToProtocolServerEvent(protocolBridge.getProtocolClient()));
|
||||
protocolBridge.getProtocolValues().eventManager.executeEvent(new ConnectedToProtocolServerEvent(protocolBridge.getProtocolClient()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.openautonomousconnection.protocol.packets.v1_0_0.beta;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.utils.ClientID;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
@@ -33,7 +34,7 @@ public final class INSQueryPacket extends OACPacket {
|
||||
@Getter
|
||||
private INSRecordType type;
|
||||
@Getter
|
||||
private int clientId;
|
||||
private ClientID clientId;
|
||||
|
||||
/**
|
||||
* Creates a new INS query packet with all required parameters.
|
||||
@@ -44,7 +45,7 @@ public final class INSQueryPacket extends OACPacket {
|
||||
* @param type Record type requested.
|
||||
* @param clientId Sender client ID for routing.
|
||||
*/
|
||||
public INSQueryPacket(String tln, String name, String sub, INSRecordType type, int clientId) {
|
||||
public INSQueryPacket(String tln, String name, String sub, INSRecordType type, ClientID clientId) {
|
||||
super(5, ProtocolVersion.PV_1_0_0_BETA);
|
||||
this.TLN = tln;
|
||||
this.name = name;
|
||||
@@ -72,7 +73,7 @@ public final class INSQueryPacket extends OACPacket {
|
||||
if (sub != null) out.writeUTF(sub);
|
||||
|
||||
out.writeObject(type);
|
||||
out.writeInt(clientId);
|
||||
out.writeObject(clientId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,6 +88,6 @@ public final class INSQueryPacket extends OACPacket {
|
||||
sub = hasSub ? in.readUTF() : null;
|
||||
|
||||
type = (INSRecordType) in.readObject();
|
||||
clientId = in.readInt();
|
||||
clientId = (ClientID) in.readObject();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.openautonomousconnection.protocol.packets.v1_0_0.beta;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.utils.ClientID;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
@@ -35,7 +36,7 @@ public final class INSResponsePacket extends OACPacket {
|
||||
@Getter
|
||||
private List<INSRecord> records;
|
||||
@Getter
|
||||
private int clientId;
|
||||
private ClientID clientId;
|
||||
|
||||
/**
|
||||
* Creates a populated response packet.
|
||||
@@ -45,7 +46,7 @@ public final class INSResponsePacket extends OACPacket {
|
||||
* @param clientId ID of requesting client.
|
||||
* @param bridge Protocol runtime context.
|
||||
*/
|
||||
public INSResponsePacket(INSResponseStatus status, List<INSRecord> records, int clientId, ProtocolBridge bridge) {
|
||||
public INSResponsePacket(INSResponseStatus status, List<INSRecord> records, ClientID clientId, ProtocolBridge bridge) {
|
||||
super(6, ProtocolVersion.PV_1_0_0_BETA);
|
||||
this.status = status;
|
||||
this.records = records;
|
||||
@@ -75,7 +76,7 @@ public final class INSResponsePacket extends OACPacket {
|
||||
out.writeObject(rec);
|
||||
}
|
||||
|
||||
out.writeInt(clientId);
|
||||
out.writeObject(clientId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +93,7 @@ public final class INSResponsePacket extends OACPacket {
|
||||
records.add((INSRecord) in.readObject());
|
||||
}
|
||||
|
||||
clientId = in.readInt();
|
||||
clientId = (ClientID) in.readObject();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package org.openautonomousconnection.protocol.packets.v1_0_0.beta;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
/**
|
||||
* Internal compatibility packet used when a classic-protocol packet is received
|
||||
* but not supported by the current protocol version.
|
||||
* <p>
|
||||
* Instead of rejecting the packet entirely, the content and class name are forwarded
|
||||
* to the appropriate compatibility handler:
|
||||
* <ul>
|
||||
* <li>{@link org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerINSServer}</li>
|
||||
* <li>{@link org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerClient}</li>
|
||||
* <li>{@link org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerWebServer}</li>
|
||||
* </ul>
|
||||
*/
|
||||
public final class UnsupportedClassicPacket extends OACPacket {
|
||||
private Class<? extends OACPacket> unsupportedClassicPacket;
|
||||
private Object[] content;
|
||||
private ProtocolBridge protocolBridge;
|
||||
|
||||
/**
|
||||
* Constructs a packet describing the unsupported classic packet and its content.
|
||||
*
|
||||
* @param unsupportedClassicPacket The packet class that was not understood.
|
||||
* @param content Serialized field values.
|
||||
* @param protocolBridge The protocol context.
|
||||
*/
|
||||
public UnsupportedClassicPacket(Class<? extends OACPacket> unsupportedClassicPacket, Object[] content, ProtocolBridge protocolBridge) {
|
||||
this();
|
||||
this.unsupportedClassicPacket = unsupportedClassicPacket;
|
||||
this.content = content;
|
||||
this.protocolBridge = protocolBridge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registration Constructor
|
||||
*/
|
||||
public UnsupportedClassicPacket() {
|
||||
super(7, ProtocolVersion.PV_1_0_0_BETA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the class name and serialized object fields to the stream.
|
||||
*/
|
||||
@Override
|
||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||
if (protocolBridge.isRunningAsClient())
|
||||
objectOutputStream.writeInt(protocolBridge.getProtocolClient().getClientINSConnection().getClientID());
|
||||
|
||||
objectOutputStream.writeUTF(unsupportedClassicPacket.getName());
|
||||
objectOutputStream.writeInt(content.length);
|
||||
for (Object o : content) objectOutputStream.writeObject(o);
|
||||
setResponseCode(INSResponseStatus.RESPONSE_NOT_REQUIRED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the unsupported packet data and forwards it to the appropriate compatibility handler.
|
||||
*/
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
int clientID = 0;
|
||||
if (protocolBridge.isRunningAsINSServer()) clientID = objectInputStream.readInt();
|
||||
String className = objectInputStream.readUTF();
|
||||
int size = objectInputStream.readInt();
|
||||
content = new Object[size];
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
content[i] = objectInputStream.readObject();
|
||||
}
|
||||
|
||||
if (protocolBridge.isRunningAsINSServer())
|
||||
protocolBridge.getClassicHandlerINSServer().unsupportedClassicPacket(className, content, protocolBridge.getProtocolServer().getClientByID(clientID));
|
||||
else if (protocolBridge.isRunningAsClient())
|
||||
protocolBridge.getClassicHandlerClient().unsupportedClassicPacket(className, content);
|
||||
else if (protocolBridge.isRunningAsWebServer())
|
||||
protocolBridge.getClassicHandlerWebServer().unsupportedClassicPacket(className, content, protocolBridge.getProtocolServer().getClientByID(clientID));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package org.openautonomousconnection.protocol.packets.v1_0_0.classic;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.events.Classic_DomainPacketReceivedEvent;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public final class Classic_DomainPacket extends OACPacket {
|
||||
private Classic_RequestDomain requestDomain;
|
||||
private Classic_Domain domain;
|
||||
private int clientID;
|
||||
private ProtocolBridge bridge;
|
||||
|
||||
public Classic_DomainPacket(int toClient, Classic_RequestDomain requestDomain, Classic_Domain domain, ProtocolBridge protocolBridge) {
|
||||
this();
|
||||
this.clientID = toClient;
|
||||
this.bridge = protocolBridge;
|
||||
|
||||
this.requestDomain = requestDomain;
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
// Registration constructor
|
||||
public Classic_DomainPacket() {
|
||||
super(2, ProtocolVersion.PV_1_0_0_CLASSIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||
if (bridge.isRunningAsINSServer()) {
|
||||
objectOutputStream.writeInt(clientID);
|
||||
objectOutputStream.writeObject(requestDomain);
|
||||
objectOutputStream.writeObject(domain);
|
||||
} else if (bridge.isRunningAsClient()) {
|
||||
clientID = bridge.getProtocolClient().getClientINSConnection().getClientID();
|
||||
objectOutputStream.writeInt(clientID);
|
||||
objectOutputStream.writeObject(requestDomain);
|
||||
}
|
||||
|
||||
objectOutputStream.writeObject(Classic_ProtocolVersion.PV_1_0_0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
if (bridge.isRunningAsINSServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
try {
|
||||
domain = bridge.getClassicHandlerINSServer().getDomain(requestDomain);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
bridge.getProtocolServer().getPipelineServer().getEventManager().executeEvent(new Classic_DomainPacketReceivedEvent(protocolVersion, domain, requestDomain, clientID));
|
||||
|
||||
if (bridge.getProtocolServer().getClientByID(clientID).supportClientClassic())
|
||||
bridge.getProtocolServer().getPipelineServer().getConnectionHandlerByID(clientID).sendPacket(new Classic_DomainPacket(clientID, requestDomain, domain, bridge));
|
||||
else
|
||||
bridge.getProtocolServer().getPipelineServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{clientID, requestDomain, domain}, bridge));
|
||||
} else if (bridge.isRunningAsClient()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
domain = (Classic_Domain) objectInputStream.readObject();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
bridge.getProtocolClient().getClientINSConnection().getEventManager().executeEvent(new Classic_DomainPacketReceivedEvent(protocolVersion, domain, requestDomain, clientID));
|
||||
} else if (bridge.isRunningAsWebServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
bridge.getProtocolServer().getPipelineServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{clientID, requestDomain, domain}, bridge));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package org.openautonomousconnection.protocol.packets.v1_0_0.classic;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
public final class Classic_MessagePacket extends OACPacket {
|
||||
private String message;
|
||||
private int clientID;
|
||||
private ProtocolBridge bridge;
|
||||
|
||||
// Constructor with message and client id
|
||||
public Classic_MessagePacket(String message, int clientID, ProtocolBridge bridge) {
|
||||
this();
|
||||
this.message = message;
|
||||
this.clientID = clientID;
|
||||
this.bridge = bridge;
|
||||
}
|
||||
|
||||
public Classic_MessagePacket() {
|
||||
super(3, ProtocolVersion.PV_1_0_0_CLASSIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||
if (bridge.isRunningAsINSServer() || bridge.isRunningAsWebServer())
|
||||
objectOutputStream.writeInt(clientID);
|
||||
else if (bridge.isRunningAsClient()) {
|
||||
clientID = bridge.getProtocolClient().getClientINSConnection().getClientID();
|
||||
objectOutputStream.writeInt(clientID);
|
||||
}
|
||||
|
||||
objectOutputStream.writeUTF(message);
|
||||
objectOutputStream.writeObject(Classic_ProtocolVersion.PV_1_0_0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
if (bridge.isRunningAsINSServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
String message = objectInputStream.readUTF();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
bridge.getClassicHandlerINSServer().handleMessage(bridge.getProtocolServer().getClientByID(clientID), message, protocolVersion);
|
||||
} else if (bridge.isRunningAsClient()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
String message = objectInputStream.readUTF();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
bridge.getClassicHandlerClient().handleMessage(message, protocolVersion);
|
||||
} else if (bridge.isRunningAsWebServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
String message = objectInputStream.readUTF();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
bridge.getClassicHandlerWebServer().handleMessage(bridge.getProtocolServer().getClientByID(clientID), message, protocolVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package org.openautonomousconnection.protocol.packets.v1_0_0.classic;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseStatus;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.events.Classic_PingPacketReceivedEvent;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public final class Classic_PingPacket extends OACPacket {
|
||||
private Classic_RequestDomain requestDomain;
|
||||
private Classic_Domain domain;
|
||||
private int clientID;
|
||||
private boolean reachable;
|
||||
private Classic_ProtocolVersion protocolVersion;
|
||||
private ProtocolBridge bridge;
|
||||
|
||||
public Classic_PingPacket(Classic_RequestDomain requestDomain, Classic_Domain domain, boolean reachable, ProtocolBridge bridge) {
|
||||
this();
|
||||
this.bridge = bridge;
|
||||
|
||||
this.requestDomain = requestDomain;
|
||||
this.domain = domain;
|
||||
this.reachable = reachable;
|
||||
this.protocolVersion = Classic_ProtocolVersion.PV_1_0_0;
|
||||
}
|
||||
|
||||
public Classic_PingPacket() {
|
||||
super(1, ProtocolVersion.PV_1_0_0_CLASSIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||
if (bridge.isRunningAsINSServer()) {
|
||||
objectOutputStream.writeInt(clientID);
|
||||
objectOutputStream.writeObject(requestDomain);
|
||||
objectOutputStream.writeObject(domain);
|
||||
objectOutputStream.writeBoolean(reachable);
|
||||
} else if (bridge.isRunningAsClient()) {
|
||||
clientID = bridge.getProtocolClient().getClientINSConnection().getClientID();
|
||||
objectOutputStream.writeInt(clientID);
|
||||
objectOutputStream.writeObject(requestDomain);
|
||||
}
|
||||
|
||||
objectOutputStream.writeObject(protocolVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
if (bridge.isRunningAsINSServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
try {
|
||||
domain = bridge.getClassicHandlerINSServer().ping(requestDomain);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
reachable = domain != null;
|
||||
bridge.getProtocolServer().getPipelineServer().getEventManager().executeEvent(new Classic_PingPacketReceivedEvent(protocolVersion, domain, requestDomain, reachable, clientID));
|
||||
if (bridge.getProtocolServer().getClientByID(clientID).supportClientClassic())
|
||||
bridge.getProtocolServer().getPipelineServer().getConnectionHandlerByID(clientID).sendPacket(new Classic_PingPacket(requestDomain, domain, reachable, bridge));
|
||||
else
|
||||
bridge.getProtocolServer().getPipelineServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{requestDomain, domain, reachable}, bridge));
|
||||
} else if (bridge.isRunningAsClient()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
domain = (Classic_Domain) objectInputStream.readObject();
|
||||
boolean reachable = objectInputStream.readBoolean();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
bridge.getClassicHandlerClient().validationCompleted(domain, reachable ? INSResponseStatus.OK : INSResponseStatus.NOT_FOUND);
|
||||
bridge.getProtocolClient().getClientINSConnection().getEventManager().executeEvent(new Classic_PingPacketReceivedEvent(protocolVersion, domain, requestDomain, reachable, clientID));
|
||||
} else if (bridge.isRunningAsWebServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
bridge.getProtocolServer().getPipelineServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{requestDomain}, bridge));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user