public PacketChannelFactory(IMqttChannelFactory innerChannelFactory,
                             IMqttTopicEvaluator topicEvaluator,
                             MqttConfiguration configuration)
     : this(topicEvaluator, configuration)
 {
     this.innerChannelFactory = innerChannelFactory;
 }
 protected ProtocolFlowProvider(IMqttTopicEvaluator topicEvaluator,
                                IRepositoryProvider repositoryProvider,
                                MqttConfiguration configuration)
 {
     this.topicEvaluator     = topicEvaluator;
     this.repositoryProvider = repositoryProvider;
     this.configuration      = configuration;
 }
示例#3
0
 public PublishReceiverFlow(IMqttTopicEvaluator topicEvaluator,
                            IRepository <RetainedMessage> retainedRepository,
                            IRepository <ClientSession> sessionRepository,
                            MqttConfiguration configuration)
     : base(sessionRepository, configuration)
 {
     this.topicEvaluator     = topicEvaluator;
     this.retainedRepository = retainedRepository;
 }
示例#4
0
        public void when_writing_invalid_subscribe_packet_then_fails(string jsonPath)
        {
            jsonPath = Path.Combine(Environment.CurrentDirectory, jsonPath);

            IMqttTopicEvaluator topicEvaluator = Mock.Of <IMqttTopicEvaluator>(e => e.IsValidTopicFilter(It.IsAny <string>()) == true);
            SubscribeFormatter  formatter      = new SubscribeFormatter(topicEvaluator);
            Subscribe           subscribe      = Packet.ReadPacket <Subscribe>(jsonPath);

            AggregateException ex = Assert.Throws <AggregateException>(() => formatter.FormatAsync(subscribe).Wait());

            Assert.True(ex.InnerException is MqttProtocolViolationException);
        }
示例#5
0
        public void when_reading_invalid_topic_filter_in_subscribe_packet_then_fails(string packetPath)
        {
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);

            IMqttTopicEvaluator topicEvaluator = Mock.Of <IMqttTopicEvaluator>(e => e.IsValidTopicFilter(It.IsAny <string>()) == true);
            SubscribeFormatter  formatter      = new SubscribeFormatter(topicEvaluator);

            byte[] packet = Packet.ReadAllBytes(packetPath);

            AggregateException ex = Assert.Throws <AggregateException>(() => formatter.FormatAsync(packet).Wait());

            Assert.True(ex.InnerException is MqttProtocolViolationException);
        }
示例#6
0
 public ServerSubscribeFlow(IMqttTopicEvaluator topicEvaluator,
                            IRepository <ClientSession> sessionRepository,
                            IRepository <RetainedMessage> retainedRepository,
                            IPacketIdProvider packetIdProvider,
                            IPublishSenderFlow senderFlow,
                            MqttConfiguration configuration)
 {
     _topicEvaluator     = topicEvaluator;
     _sessionRepository  = sessionRepository;
     _retainedRepository = retainedRepository;
     _packetIdProvider   = packetIdProvider;
     _senderFlow         = senderFlow;
     _configuration      = configuration;
 }
 public ServerProtocolFlowProvider(IMqttAuthenticationProvider authenticationProvider,
                                   IConnectionProvider connectionProvider,
                                   IMqttTopicEvaluator topicEvaluator,
                                   IRepositoryProvider repositoryProvider,
                                   IPacketIdProvider packetIdProvider,
                                   ISubject <MqttUndeliveredMessage> undeliveredMessagesListener,
                                   MqttConfiguration configuration)
     : base(topicEvaluator, repositoryProvider, configuration)
 {
     _authenticationProvider      = authenticationProvider;
     _connectionProvider          = connectionProvider;
     _packetIdProvider            = packetIdProvider;
     _undeliveredMessagesListener = undeliveredMessagesListener;
 }
示例#8
0
        public async Task when_writing_publish_packet_then_succeeds(string jsonPath, string packetPath)
        {
            jsonPath   = Path.Combine(Environment.CurrentDirectory, jsonPath);
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);

            byte[] expectedPacket = Packet.ReadAllBytes(packetPath);
            IMqttTopicEvaluator topicEvaluator = Mock.Of <IMqttTopicEvaluator>(e => e.IsValidTopicName(It.IsAny <string>()) == true);
            PublishFormatter    formatter      = new PublishFormatter(topicEvaluator);
            Publish             publish        = Packet.ReadPacket <Publish>(jsonPath);

            byte[] result = await formatter.FormatAsync(publish);

            expectedPacket.Should().BeEquivalentTo(result);
        }
示例#9
0
        public async Task when_reading_subscribe_packet_then_succeeds(string packetPath, string jsonPath)
        {
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);
            jsonPath   = Path.Combine(Environment.CurrentDirectory, jsonPath);

            Subscribe           expectedSubscribe = Packet.ReadPacket <Subscribe>(jsonPath);
            IMqttTopicEvaluator topicEvaluator    = Mock.Of <IMqttTopicEvaluator>(e => e.IsValidTopicFilter(It.IsAny <string>()) == true);
            SubscribeFormatter  formatter         = new SubscribeFormatter(topicEvaluator);

            byte[] packet = Packet.ReadAllBytes(packetPath);

            IPacket result = await formatter.FormatAsync(packet);

            expectedSubscribe.Should().Be(result);
        }
示例#10
0
        public void when_creating_packet_channel_then_succeeds()
        {
            MqttConfiguration configuration = new MqttConfiguration {
                WaitTimeoutSecs = 1
            };
            Subject <byte[]> receiver = new Subject <byte[]>();
            Mock <IMqttChannel <byte[]> > bufferedChannel = new Mock <IMqttChannel <byte[]> >();

            bufferedChannel.Setup(x => x.ReceiverStream).Returns(receiver);

            IMqttTopicEvaluator    topicEvaluator = Mock.Of <IMqttTopicEvaluator>();
            PacketChannelFactory   factory        = new PacketChannelFactory(topicEvaluator, configuration);
            IMqttChannel <IPacket> channel        = factory.Create(bufferedChannel.Object);

            Assert.NotNull(channel);
        }
示例#11
0
 public ServerPublishReceiverFlow(IMqttTopicEvaluator topicEvaluator,
                                  IConnectionProvider connectionProvider,
                                  IPublishSenderFlow senderFlow,
                                  IRepository <RetainedMessage> retainedRepository,
                                  IRepository <ClientSession> sessionRepository,
                                  IRepository <ConnectionWill> willRepository,
                                  IPacketIdProvider packetIdProvider,
                                  ISubject <MqttUndeliveredMessage> undeliveredMessagesListener,
                                  MqttConfiguration configuration)
     : base(topicEvaluator, retainedRepository, sessionRepository, configuration)
 {
     _connectionProvider          = connectionProvider;
     _senderFlow                  = senderFlow;
     _willRepository              = willRepository;
     _packetIdProvider            = packetIdProvider;
     _undeliveredMessagesListener = undeliveredMessagesListener;
 }
 public SubscribeFormatter(IMqttTopicEvaluator topicEvaluator)
 {
     this.topicEvaluator = topicEvaluator;
 }
示例#13
0
 public PublishFormatter(IMqttTopicEvaluator topicEvaluator)
 {
     _topicEvaluator = topicEvaluator;
 }
 public PacketChannelFactory(IMqttTopicEvaluator topicEvaluator,
                             MqttConfiguration configuration)
 {
     this.topicEvaluator = topicEvaluator;
     this.configuration  = configuration;
 }
示例#15
0
 public ClientProtocolFlowProvider(IMqttTopicEvaluator topicEvaluator,
                                   IRepositoryProvider repositoryProvider,
                                   MqttConfiguration configuration)
     : base(topicEvaluator, repositoryProvider, configuration)
 {
 }