mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-27 02:40:51 +01:00
packets stuff
This commit is contained in:
parent
690e9c1f2b
commit
4849cb5479
@ -35,11 +35,13 @@ public class UnityCommunicator {
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session) throws IOException {
|
||||
session.setMaxBinaryMessageBufferSize(1024 * 1024 * 100);
|
||||
session.setMaxBinaryMessageBufferSize(1024 * 1024 * 10);
|
||||
}
|
||||
|
||||
private int lastType = 2; // 0 = incoming, 1 = outgoing, 2 = expect new
|
||||
|
||||
@OnMessage
|
||||
public void onMessage(byte[] b, Session session) throws IOException {
|
||||
public void onMessage(byte[] b, boolean isLast, Session session) throws IOException {
|
||||
if (allowedSession != null && !session.getId().equals(allowedSession)) {
|
||||
return;
|
||||
}
|
||||
@ -47,10 +49,15 @@ public class UnityCommunicator {
|
||||
if (revision == null) {
|
||||
revision = new String(b, StandardCharsets.ISO_8859_1);
|
||||
allowedSession = session.getId();
|
||||
if (!isLast) {
|
||||
System.out.println("this is bad");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] packet = Arrays.copyOfRange(b, 1, b.length);
|
||||
|
||||
|
||||
byte[] packet = lastType == 2 ? Arrays.copyOfRange(b, 1, b.length) : b;
|
||||
|
||||
if (hProxy == null && b[0] == 1) {
|
||||
HPacket maybe = new HPacket(packet);
|
||||
@ -67,11 +74,13 @@ public class UnityCommunicator {
|
||||
}
|
||||
|
||||
|
||||
if (hProxy != null && b[0] == 0) {
|
||||
if (hProxy != null && ((lastType == 2 && b[0] == 0) || lastType == 0)) {
|
||||
hProxy.getInHandler().act(packet);
|
||||
lastType = isLast ? 2 : 0;
|
||||
}
|
||||
else if (hProxy != null && b[0] == 1) {
|
||||
else if (hProxy != null && ((lastType == 2 && b[0] == 1) || lastType == 1)) {
|
||||
hProxy.getOutHandler().act(packet);
|
||||
lastType = isLast ? 2 : 1;
|
||||
}
|
||||
else {
|
||||
proxyProvider.abort();
|
||||
|
@ -25,12 +25,12 @@ public class UnityPacketHandler extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void sendToStream(byte[] buffer) {
|
||||
// synchronized (session) {
|
||||
synchronized (session) {
|
||||
byte[] prefix = new byte[]{(direction == HMessage.Direction.TOCLIENT ? ((byte)0) : ((byte)1))};
|
||||
byte[] combined = ByteArrayUtils.combineByteArrays(prefix, buffer);
|
||||
|
||||
session.getAsyncRemote().sendBinary(ByteBuffer.wrap(combined));
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,7 +125,7 @@ public class UiLoggerController implements Initializable {
|
||||
elements.add(new Element("]", "incoming"));
|
||||
|
||||
elements.add(new Element(" <- ", ""));
|
||||
if (skiphugepackets && packet.length() > 8000) {
|
||||
if (skiphugepackets && packet.length() > 4000) {
|
||||
elements.add(new Element("<packet skipped>", "skipped"));
|
||||
}
|
||||
else {
|
||||
|
@ -87,6 +87,11 @@ let _g_packet_split = 600;
|
||||
|
||||
function inject_out(packet) {
|
||||
|
||||
if (chachas.length > 1) {
|
||||
packet[5] = _gearth_returnbyte_copy(chachas[0], packet[5], chachaClass);
|
||||
packet[4] = _gearth_returnbyte_copy(chachas[0], packet[4], chachaClass);
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
while (i < packet.length) {
|
||||
let inject_amount = Math.min(_g_packet_split, packet.length - i);
|
||||
@ -97,11 +102,6 @@ function inject_out(packet) {
|
||||
unityInstance.Module.HEAPU8.set(writeLittleEndian(inject_amount), packet_location + 12);
|
||||
unityInstance.Module.HEAPU8.set(packet.slice(i, i + inject_amount), packet_location + 16);
|
||||
|
||||
if (i === 0 && chachas.length > 1) {
|
||||
unityInstance.Module.HEAPU8[packet_location + 16 + 5] = _gearth_returnbyte_copy(chachas[0], unityInstance.Module.HEAPU8[packet_location + 16 + 5], chachaClass);
|
||||
unityInstance.Module.HEAPU8[packet_location + 16 + 4] = _gearth_returnbyte_copy(chachas[0], unityInstance.Module.HEAPU8[packet_location + 16 + 4], chachaClass);
|
||||
}
|
||||
|
||||
_gearth_outgoing_copy(out_send_param1, packet_location, out_send_param3);
|
||||
_free(packet_location);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user