From 25ab3747eb940c577bd0cb18de8c0942c63fa3f9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 29 Mar 2024 10:07:33 -0400 Subject: [PATCH] Handler written for protocol class --- src/engine/net/client/Protocol.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index 3c68e34f..4c7a727b 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -286,6 +286,33 @@ public enum Protocol { } } + public static boolean handleClientMsg(ClientNetMsg msg) { + + if (msg == null) + return false; + + try { + + Protocol protocol = msg.getProtocolMsg(); + + // Unhandled opcode + + if (protocol == null) + return true; + + AbstractClientMsgHandler msgHandler = protocol.handler; + + if (msgHandler == null) + return true; + + } catch (Exception e) { + Logger.error("handler for " + msg.getProtocolMsg() + " failed: " + e); + return false; + } + + return true; + } + public static Protocol getByOpcode(int opcode) { Protocol protocol = _protocolMsgByOpcode.get(opcode);