mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-27 02:40:51 +01:00
packet expression things
This commit is contained in:
parent
1d1831cc94
commit
1f58290393
@ -537,25 +537,44 @@ public class HPacket implements StringifyAble {
|
|||||||
isEdited = edited;
|
isEdited = edited;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toExpression(HMessage.Direction direction) {
|
private String getHarbleStructure(HMessage.Direction direction) {
|
||||||
if (isCorrupted()) return "";
|
|
||||||
|
|
||||||
HarbleAPI.HarbleMessage msg;
|
HarbleAPI.HarbleMessage msg;
|
||||||
if (HarbleAPIFetcher.HARBLEAPI != null &&
|
if (HarbleAPIFetcher.HARBLEAPI != null &&
|
||||||
((msg = HarbleAPIFetcher.HARBLEAPI.getHarbleMessageFromHeaderId(direction, headerId())) != null)) {
|
((msg = HarbleAPIFetcher.HARBLEAPI.getHarbleMessageFromHeaderId(direction, headerId())) != null)) {
|
||||||
if (msg.getStructure() != null) {
|
if (msg.getStructure() != null && structureEquals(msg.getStructure())) {
|
||||||
return PacketStringUtils.toExpressionFromGivenStructure(this, msg.getStructure());
|
return msg.getStructure();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return toExpression();
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toExpression(HMessage.Direction direction) {
|
||||||
|
if (isCorrupted()) return "";
|
||||||
|
|
||||||
|
String structure = getHarbleStructure(direction);
|
||||||
|
if (structure != null) {
|
||||||
|
return PacketStringUtils.toExpressionFromGivenStructure(this, structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PacketStringUtils.predictedExpression(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns "" if not found or not sure enough
|
* returns "" if not found or not sure enough
|
||||||
* dont hate on the coding quality in this function, its pretty effective.
|
|
||||||
*/
|
*/
|
||||||
public String toExpression() {
|
public String toExpression() {
|
||||||
if (isCorrupted()) return "";
|
if (isCorrupted()) return "";
|
||||||
|
|
||||||
|
String structure1 = getHarbleStructure(HMessage.Direction.TOCLIENT);
|
||||||
|
String structure2 = getHarbleStructure(HMessage.Direction.TOSERVER);
|
||||||
|
if (structure1 != null && structure2 == null) {
|
||||||
|
return PacketStringUtils.toExpressionFromGivenStructure(this, structure1);
|
||||||
|
}
|
||||||
|
else if (structure1 == null && structure2 != null) {
|
||||||
|
return PacketStringUtils.toExpressionFromGivenStructure(this, structure2);
|
||||||
|
}
|
||||||
|
|
||||||
return PacketStringUtils.predictedExpression(this);
|
return PacketStringUtils.predictedExpression(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Jonas on 21/06/18.
|
* Created by Jonas on 21/06/18.
|
||||||
@ -224,7 +225,7 @@ public class NetworkExtension extends GEarthExtension {
|
|||||||
public void packetToStringResponse(String string, String expression) {
|
public void packetToStringResponse(String string, String expression) {
|
||||||
HPacket packet = new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.PACKETTOSTRING_RESPONSE);
|
HPacket packet = new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.PACKETTOSTRING_RESPONSE);
|
||||||
packet.appendLongString(string);
|
packet.appendLongString(string);
|
||||||
packet.appendLongString(expression);
|
packet.appendLongString(expression, StandardCharsets.UTF_8);
|
||||||
sendMessage(packet);
|
sendMessage(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user