public void AddPacketToStack(PacketData data) { PacketStackItem stackItem = new PacketStackItem(); stackItem.Packet = data; stackItem.Time = DateTime.Now; main.PacketStack.Add(stackItem); }
private bool PacketInStack(PacketData data) { for (int x = 0; x < main.PacketStack.Count; x++) { PacketStackItem item = main.PacketStack[x]; if (item.Packet.PacketID == data.PacketID) { return(true); } } AddPacketToStack(data); //Remove stack items older than 2 minutes main.PacketStack.RemoveAll(item => item.Time < DateTime.Now.AddMinutes(-2)); return(false); }