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); }
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); }
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); }