예제 #1
0
        private void ProcessSubscription()
        {
            SubAck    ack    = new SubAck(_command.MessageId);
            Subscribe subCmd = _command as Subscribe;

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

            _connection.Send(new SubAck(_command.MessageId));
            _connection.Complete(_command);
        }
예제 #2
0
        public override void Start()
        {
            switch (_command.Header.QualityOfService)
            {
            case QualityOfService.AtMostOnce:
                _connection.Complete(_command);
                break;

            case QualityOfService.AtLeastOnce:
                _connection.Send(new PubAck(_command.MessageId));
                _connection.Complete(_command);
                break;

            case QualityOfService.ExactlyOnce:
                _connection.Send(new PubRec(_command.MessageId));
                WaitFor(_connection, _command.MessageId.Value, CommandMessage.PUBREL).Await();
                _connection.Send(new PubComp(_command.MessageId));
                _connection.Complete(_command);
                break;

            default:
                throw new InvalidOperationException("Unknown QoS");
            }
        }
예제 #3
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);
        }
예제 #4
0
 public override void Start()
 {
     _connection.Send(new PingResp());
     _connection.Complete(_command);
 }