mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-26 10:20:51 +01:00
Fix outgoing packet
This commit is contained in:
parent
368a21ffcf
commit
7a635ffe6a
@ -22,13 +22,18 @@ public class NitroPacketHandler extends PacketHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sendToStream(byte[] buffer) {
|
public boolean sendToStream(byte[] buffer) {
|
||||||
|
// Required to prevent garbage buffer within the UI logger.
|
||||||
|
if (direction == HMessage.Direction.TOSERVER) {
|
||||||
|
buffer = buffer.clone();
|
||||||
|
}
|
||||||
|
|
||||||
session.getSession().getAsyncRemote().sendBinary(ByteBuffer.wrap(buffer));
|
session.getSession().getAsyncRemote().sendBinary(ByteBuffer.wrap(buffer));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(byte[] buffer) throws IOException {
|
public void act(byte[] buffer) throws IOException {
|
||||||
HMessage hMessage = new HMessage(new HPacket(deepCopy(buffer)), direction, currentIndex);
|
HMessage hMessage = new HMessage(new HPacket(buffer), direction, currentIndex);
|
||||||
|
|
||||||
OnHMessageHandled afterExtensionIntercept = hMessage1 -> {
|
OnHMessageHandled afterExtensionIntercept = hMessage1 -> {
|
||||||
notifyListeners(2, hMessage1);
|
notifyListeners(2, hMessage1);
|
||||||
@ -44,13 +49,4 @@ public class NitroPacketHandler extends PacketHandler {
|
|||||||
|
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] deepCopy(byte[] org) {
|
|
||||||
if (org == null)
|
|
||||||
return null;
|
|
||||||
byte[] result = new byte[org.length];
|
|
||||||
System.arraycopy(org, 0, result, 0, org.length);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user