private bool ValidateFail() { if (handlers.Length == 0) { return(false); } PacketOpcode.SERVER max = Enum.GetValues(typeof(PacketOpcode.SERVER)).Cast <PacketOpcode.SERVER>().Last(); bool[] test = new bool[(int)max + 1]; foreach (AbstractClientPacketHandle handle in handlers) { if (handle == null) { continue; } if (test[(int)handle.getOpcode()]) { return(true); } else { test[(int)handle.getOpcode()] = true; } } return(false); }
public void DeRegisterHandler(PacketOpcode.SERVER code) { if (registered[(short)code] == null) { Debug.Log("handler code not in list."); return; } registered[(short)code] = null; }
public void RegisterHandler(PacketOpcode.SERVER code, AbstractClientPacketHandle handler) { if (registered[(short)code] != null) { Debug.Log("handler alread in list."); return; } try { registered[(short)code] = handler; } catch (Exception e) { Debug.LogError("Error registering handler - " + code); Debug.LogError(e.Message); } }
private ClientPacketProcessor() { PacketOpcode.SERVER max = Enum.GetValues(typeof(PacketOpcode.SERVER)).Cast <PacketOpcode.SERVER>().Last(); registered = new AbstractClientPacketHandle[(short)max + 1]; }