From 484fe033c4152bb27c7d76d447e9ce27f89e36b0 Mon Sep 17 00:00:00 2001 From: Obique Date: Sun, 4 Feb 2018 13:08:51 -0600 Subject: [PATCH] Fixed timing issue with inbound packets --- src/network/NetworkClient.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/network/NetworkClient.java b/src/network/NetworkClient.java index 28b9fafed..6748c33fb 100644 --- a/src/network/NetworkClient.java +++ b/src/network/NetworkClient.java @@ -75,6 +75,7 @@ public class NetworkClient extends TCPSession { public void close(ConnectionStoppedReason reason) { if (sessionManager.getStatus() != SessionStatus.DISCONNECTED) { + sendPacket(new HoloConnectionStopped(reason)); sessionManager.onSessionDestroyed(); intentChain.broadcastAfter(new ConnectionClosedIntent(getSessionId(), reason)); try { @@ -128,16 +129,18 @@ public class NetworkClient extends TCPSession { @Override protected void onIncomingData(byte[] data) { + boolean canDecode = false; inboundLock.lock(); try { buffer.write(data); - if (NetworkProtocol.canDecode(buffer)) - InboundPacketPendingIntent.broadcast(this); + canDecode = NetworkProtocol.canDecode(buffer); } catch (IOException e) { close(ConnectionStoppedReason.INVALID_PROTOCOL); } finally { inboundLock.unlock(); } + if (canDecode) + InboundPacketPendingIntent.broadcast(this); } @Override