Ejemplo n.º 1
0
        private Task ProcessSubscription(MqttCommand msg, Action<MqttCommand> release)
        {
            SubAck ack = new SubAck(msg.MessageId);
            Subscribe subCmd = msg as Subscribe;
            foreach (Subscription sub in subCmd.Subscriptions)
            {
                ack.Grants.Add(QualityOfService.AtMostOnce);
            }

            return Send(ack)
                .ContinueWith((task) =>
                    Task.Factory.StartNew(() => release(msg)),
                    TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.LongRunning);
        }
Ejemplo n.º 2
0
        private void ProcessSubscription()
        {
            var subCmd = _command as Subscribe;
            if (subCmd == null)
            {
                throw new InvalidOperationException("Command was not of type Subscribe");
            }

            var ack = new SubAck(_command.MessageId);

            foreach (Subscription sub in subCmd.Subscriptions)
            {
                ack.Grants.Add(QualityOfService.AtMostOnce);
            }

            _connection.Send(new SubAck(_command.MessageId));
            _connection.Complete(_command);
        }
Ejemplo n.º 3
0
        private Task ProcessSubscription(MqttCommand msg, Action<MqttCommand> release)
        {
            var ack = new SubAck(msg.MessageId);
            var subCmd = msg as Subscribe;
            if (subCmd == null)
            {
                throw new InvalidOperationException("Subscribe operationg expects Subscribe command");
            }

            foreach (Subscription sub in subCmd.Subscriptions)
            {
                ack.Grants.Add(QualityOfService.AtMostOnce);
            }

            return Send(ack)
                .ContinueWith(task =>
                    Task.Factory.StartNew(() => release(msg)),
                    TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.LongRunning);
        }