// Checks whether the event has been processed already or not. public bool ShouldProcessEvent(Event ievent) { Event lastAckedEvent = _lastAcked.Find(ev => ev.ClientId == ievent.ClientId && ev.GetEventEnum().Equals(ievent.GetEventEnum())); return(lastAckedEvent == null || UnsignedCircularComparator.compareLong((ulong)ievent.SeqId, (ulong)lastAckedEvent.SeqId, (ulong)Connection.MAX_SEQ_ID) == 1); }
// When acking an event, all events of the same kind and same client with lower seq id will be removed. // The last acked event will be stored in order to check if it has been already processed. public void AckEvent(Event ievent) { _eventQueue = _eventQueue.Where(ev => !(ev.ClientId == ievent.ClientId && ev.GetEventEnum().Equals(ievent.GetEventEnum()) && UnsignedCircularComparator.compareLong((ulong)ev.SeqId, (ulong)ievent.SeqId, (ulong)Connection.MAX_SEQ_ID) < 1)) .ToList(); _lastAcked = _lastAcked.Where(ev => !(ev.ClientId == ievent.ClientId && ev.GetEventEnum().Equals(ievent.GetEventEnum()))).ToList(); _lastAcked.Add(ievent); }