예제 #1
0
        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);
        }
예제 #2
0
        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);
        }