public DequeueHint GetDequeueHint(IEnumerable <long> deviceIds) { var dequeueHint = new DequeueHint(); lock (_lock) { foreach (var deviceId in deviceIds) { DeviceEntry currentEntry; if (_deviceEntries.TryGetValue(deviceId, out currentEntry)) { if (currentEntry.DequeueIndex < currentEntry.EnqueueIndex) { dequeueHint.NewMessages.Add(currentEntry.Clone()); } } else { dequeueHint.UnknownDevices.Add(deviceId); } } } return(dequeueHint); }
public static IReadOnlyCollection <DeviceIdWithOpHint> ToDeviceIdWithOpHint(DequeueHint dequeueHint) { var result = new List <DeviceIdWithOpHint>(); foreach (var deviceEntry in dequeueHint.NewMessages) { result.Add(new DeviceIdWithOpHint { DeviceId = deviceEntry.Id, Index = deviceEntry.DequeueIndex }); } foreach (var unknownDevice in dequeueHint.UnknownDevices) { result.Add(new DeviceIdWithOpHint { DeviceId = unknownDevice, Index = null }); } return(result); }